ConsoleTools: ezcConsoleQuestionDialogCollectionValidator
[ ]
[ ]
[ ]
[ ]
[ ]
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.
Descendents
Properties
|
array |
read/write
|
$collection
The collection of valid answers. |
|
int |
read/write
|
$conversion
ezcConsoleDialogValidator::CONVERT_NONE (default) or ezcConsoleDialogValidator::CONVERT_LOWER or ezcConsoleDialogValidator::CONVERT_UPPER. |
|
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. |
Redefined in descendants as
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. |
Redefined in descendants as
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: Mon, 29 Jun 2009