## Apache Zeta Components Manual :: Docs For Class ezcConsoleQuestionDialogTypeValidator

### ConsoleTools::ezcConsoleQuestionDialogTypeValidator

### Class ezcConsoleQuestionDialogTypeValidator

Validator class to validate a certain data type.

Validator class for ezcConsoleQuestionDialog objects that validates a certain datatype.

Source for this file: /ConsoleTools/src/dialog/validators/question_dialog_type.php

### Implements interfaces:

- ezcConsoleQuestionDialogValidator

Version: | //autogen//

### 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.

##### Implementation of:

Method | Description
--- | ---
`ezcConsoleDialogValidator::fixup()` | Returns a fixed version of the result, if possible.

#### 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.

##### Implementation of:

Method | Description
--- | ---
`ezcConsoleQuestionDialogValidator::getResultString()` | Returns a string of possible results to be displayed with the question.

#### 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.

##### Implementation of:

Method | Description
--- | ---
`ezcConsoleDialogValidator::validate()` | Returns if the given result is valid.

Documentation generated by phpDocumentor 1.4.3