Path

ez components / documentation / api reference / 2007.2beta1 / consoletools


eZ Components 2007.2beta1

ConsoleTools: ezcConsoleQuestionDialogCollectionValidator

[ Tutorial ] [ Class tree ] [ Element index ] [ ChangeLog ] [ Credits ]

Class: ezcConsoleQuestionDialogCollectionValidator

Validator class to validate against a set of valid results. [source]

Implemented Interfaces

This validator class, for ezcConsoleQuestionDialog objects, validates a given result against a set of predefined values.

Properties

array read/write  $collection
The collection of valid answers.
int read/write  $conversion
ezcConsoleQuestionDialogCollectionValidator::TYPE_*.
mixed read/write  $default
Default value.

Member Variables

protected array $properties = array(
"collection" => array(),"default"=>null,"conversion"=>self::CONVERT_NONE,)

Properties.

Method Summary

public void __construct( $collection, [$default = null], [$conversion = self::CONVERT_NONE] )
Creates a new question dialog collection validator.
public mixed fixup( $result )
Returns a fixed version of the result, if possible.
public string getResultString( )
Returns a string representing valid results.
public bool validate( $result )
Returns if the given result is valid.

Methods

__construct

void __construct( $collection, [mixed $default = null], [int $conversion = self::CONVERT_NONE] )
Creates a new question dialog collection validator.
Creates a new question dialog collection validator, which validates the result specified by the user against an array of valid results ($collection). If not value is provided by the user a possibly set $default value is used instead. The $conversion parameter can optionally define a conversion to be performed on the result before validating it. Valid conversions are defined by the CONVERT_* constants in this class.

Parameters

Name Type Description
$collection array The collection of valid results.
$default mixed Optional default value.
$conversion int CONVERT_* constant.

fixup

mixed fixup( mixed $result )
Returns a fixed version of the result, if possible.
Converts the given result according to the conversion defined in the $conversion property.

Parameters

Name Type Description
$result mixed The received result.

getResultString

string getResultString( )
Returns a string representing valid results.
Returns the string that will be displayed with the question to indicate valid results to the user and a possibly set default, if available.

validate

bool validate( mixed $result )
Returns if the given result is valid.
Returns if the result is in the $collection array.

Parameters

Name Type Description
$result mixed The received result.

Last updated: Wed, 28 Nov 2007