Path

ez components / documentation / api reference / trunk / consoletools


eZ Components trunk

ConsoleTools: ezcConsoleQuestionDialogTypeValidator

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

Class: ezcConsoleQuestionDialogTypeValidator

Validator class to validate a certain data type. [source]

Implemented Interfaces

Validator class for ezcConsoleQuestionDialog objects that validates a certain datatype.

Constants

TYPE_BOOL = 3 Data type bool.
The results 1 and "true" will be cased to true, 0 and "false" to false.
TYPE_FLOAT = 2 Data type float.
TYPE_INT = 1 Data type int.
TYPE_STRING = 0 Data type string.

Properties

mixed read/write  $default
A default value if no result given.
int read/write  $type
One of ezcConsoleQuestionDialogTypeValidator::TYPE_*. The type to check against and convert results to.

Member Variables

protected array $properties = array(
"type" => self::TYPE_STRING,
"default" => null,
)

Properties.

Method Summary

public void __construct( [$type = self::TYPE_STRING], [$default = null] )
Creates a new question dialog type 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( [int $type = self::TYPE_STRING], [mixed $default = null] )
Creates a new question dialog type validator.
Creates a new question dialog type validator, which validates the result specified to be of a certaon type. The $type must be one of the TYPE_* constants in this class. If no value is provided by the user a possibly set $default value is used instead.

Parameters

Name Type Description
$type int One of ezcConsoleQuestionDialogTypeValidator::TYPE_*.
$default mixed Default value according to $type.

fixup

mixed fixup( mixed $result )
Returns a fixed version of the result, if possible.
Returns the value casted into the correct type or the default value, if it exists and the result is empty.

Parameters

Name Type Description
$result mixed The result received.

getResultString

string getResultString( )
Returns a string representing valid results.
Returns the string that can 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 of the given type.

Parameters

Name Type Description
$result mixed The result to check.

Last updated: Mon, 10 Nov 2008