|
eZ Publish
[trunk]
|
Input text validation and correction. More...
Inheritance diagram for eZInputValidator:Public Member Functions | |
| eZInputValidator () | |
| fixup ($text) | |
| validate ($text) | |
Public Attributes | |
| const | STATE_ACCEPTED = 1 |
| const | STATE_INTERMEDIATE = 2 |
| const | STATE_INVALID = 3 |
Input text validation and correction.
This is the base class for doing validation of input text and eventually correction. The general eZRegExpValidator can be used for most validations by supplying it with a regexp rule set, for more advanced validation you can use the eZIntegerValidator which can validate integers withing ranges.
For creating your own validators you can either inherit this class or any of the advanced classes. The inherited class must implement the validate() function for validation and fixup() for fixing text to be acceptable.
A validation will return a state which can either be Accepted, Intermediate or Invalid. Accepted means that the text can be used without modification, Invalid means that the text cannot be used at any cost while Intermediate means that the text can be used if it's fixed with the fixup() function.
Example of a simple integer validator
class IntegerValidator { function IntegerValidator() { } function validate( $text ) { return is_numeric( $text ) ? eZInputValidator::STATE_ACCEPTED : eZInputValidator::STATE_INVALID; } function fixup( $text ) { } }
Example of a boolean validator
class BooleanValidator { function BooleanValidator() { } function validate( $text ) { if ( strtolower( $text ) == "true" or strtolower( $text ) == "false" ) return eZInputValidator::STATE_ACCEPTED; if ( is_numeric( $text ) ) return eZInputValidator::STATE_INTERMEDIATE; return eZInputValidator::STATE_INVALID; } function fixup( $text ) { $text = ( $text == 0 ? "false" : "true" ); } }
Definition at line 77 of file ezinputvalidator.php.
Default constructor, does nothing.
Definition at line 86 of file ezinputvalidator.php.
Referenced by eZRegExpValidator\eZRegExpValidator().
| eZInputValidator::fixup | ( | $ | text | ) |
Tries to fix the text $text which was previously marked as eZInputValidator::STATE_INTERMEDIATE so that it can be seen as eZInputValidator::STATE_ACCEPTED.
Reimplemented in eZFloatValidator, eZIntegerValidator, and eZRegExpValidator.
Definition at line 106 of file ezinputvalidator.php.
| eZInputValidator::validate | ( | $ | text | ) |
Tries to validate to the text $text and returns one of the validator states eZInputValidator::STATE_ACCEPTED, eZInputValidator::STATE_INTERMEDIATE or eZInputValidator::STATE_INVALID. This returns eZInputValidator::STATE_ACCEPTED as default and must be reimplemented in real valiators.
Reimplemented in eZFloatValidator, eZIntegerValidator, and eZRegExpValidator.
Definition at line 97 of file ezinputvalidator.php.
| const eZInputValidator::STATE_ACCEPTED = 1 |
Definition at line 79 of file ezinputvalidator.php.
Referenced by eZShopOperationCollection\addToBasket(), eZISBNType\fetchObjectAttributeHTTPInput(), eZDataType\fixupClassAttributeHTTPInput(), eZRegExpValidator\validate(), eZIntegerValidator\validate(), eZFloatValidator\validate(), validate(), eZMultiOption2Type\validateAddToBasket(), eZDataType\validateAddToBasket(), eZSelectionType\validateClassAttributeHTTPInput(), eZIniSettingType\validateClassAttributeHTTPInput(), eZIdentifierType\validateClassAttributeHTTPInput(), eZKeywordType\validateClassAttributeHTTPInput(), eZObjectRelationType\validateClassAttributeHTTPInput(), eZURLType\validateClassAttributeHTTPInput(), eZStringType\validateClassAttributeHTTPInput(), eZFloatType\validateClassAttributeHTTPInput(), eZEnumType\validateClassAttributeHTTPInput(), eZIntegerType\validateClassAttributeHTTPInput(), eZMediaType\validateClassAttributeHTTPInput(), eZObjectRelationListType\validateClassAttributeHTTPInput(), eZDataType\validateClassAttributeHTTPInput(), eZBooleanType\validateCollectionAttributeHTTPInput(), eZTextType\validateCollectionAttributeHTTPInput(), eZEmailType\validateCollectionAttributeHTTPInput(), eZTimeType\validateCollectionAttributeHTTPInput(), eZStringType\validateCollectionAttributeHTTPInput(), eZDateType\validateCollectionAttributeHTTPInput(), eZDateTimeType\validateCollectionAttributeHTTPInput(), eZSelectionType\validateCollectionAttributeHTTPInput(), eZIntegerType\validateCollectionAttributeHTTPInput(), eZCountryType\validateCollectionAttributeHTTPInput(), eZDataType\validateCollectionAttributeHTTPInput(), eZDateTimeValidator\validateDate(), eZDateTimeValidator\validateDateTime(), eZEmailType\validateEMailHTTPInput(), eZApproveType\validateGroupIDList(), eZWorkflowType\validateHTTPInput(), eZApproveType\validateHTTPInput(), eZSimplifiedXMLInput\validateInput(), eZContentObject\validateInput(), eZIntegerType\validateIntegerHTTPInput(), eZRangeOptionType\validateObjectAttributeHTTPInput(), eZAuthorType\validateObjectAttributeHTTPInput(), eZISBNType\validateObjectAttributeHTTPInput(), eZPriceType\validateObjectAttributeHTTPInput(), eZMatrixType\validateObjectAttributeHTTPInput(), eZMultiPriceType\validateObjectAttributeHTTPInput(), eZObjectRelationListType\validateObjectAttributeHTTPInput(), eZPackageType\validateObjectAttributeHTTPInput(), eZTimeType\validateObjectAttributeHTTPInput(), eZObjectRelationType\validateObjectAttributeHTTPInput(), eZProductCategoryType\validateObjectAttributeHTTPInput(), eZIniSettingType\validateObjectAttributeHTTPInput(), eZDateType\validateObjectAttributeHTTPInput(), eZMultiOptionType\validateObjectAttributeHTTPInput(), eZMultiOption2Type\validateObjectAttributeHTTPInput(), eZUserType\validateObjectAttributeHTTPInput(), eZOptionType\validateObjectAttributeHTTPInput(), eZBooleanType\validateObjectAttributeHTTPInput(), eZEmailType\validateObjectAttributeHTTPInput(), eZKeywordType\validateObjectAttributeHTTPInput(), eZURLType\validateObjectAttributeHTTPInput(), eZTextType\validateObjectAttributeHTTPInput(), eZDateTimeType\validateObjectAttributeHTTPInput(), eZStringType\validateObjectAttributeHTTPInput(), eZFloatType\validateObjectAttributeHTTPInput(), eZIntegerType\validateObjectAttributeHTTPInput(), eZSelectionType\validateObjectAttributeHTTPInput(), eZMediaType\validateObjectAttributeHTTPInput(), eZEnumType\validateObjectAttributeHTTPInput(), eZCountryType\validateObjectAttributeHTTPInput(), eZImageType\validateObjectAttributeHTTPInput(), eZBinaryFileType\validateObjectAttributeHTTPInput(), eZDataType\validateObjectAttributeHTTPInput(), eZStringType\validateStringHTTPInput(), eZDateTimeValidator\validateTime(), and eZApproveType\validateUserIDList().
| const eZInputValidator::STATE_INTERMEDIATE = 2 |
Definition at line 80 of file ezinputvalidator.php.
Referenced by eZRegExpValidator\validate(), eZFloatValidator\validate(), eZIntegerValidator\validate(), eZIdentifierType\validateClassAttributeHTTPInput(), eZFloatType\validateClassAttributeHTTPInput(), eZIntegerType\validateClassAttributeHTTPInput(), eZContentObject\validateInput(), eZIntegerType\validateIntegerHTTPInput(), and eZObjectRelationListType\validateObjectAttributeHTTPInput().
| const eZInputValidator::STATE_INVALID = 3 |
Definition at line 81 of file ezinputvalidator.php.
Referenced by eZRegExpValidator\validate(), eZMultiOption2Type\validateAddToBasket(), eZIniSettingType\validateClassAttributeHTTPInput(), eZIdentifierType\validateClassAttributeHTTPInput(), eZObjectRelationType\validateClassAttributeHTTPInput(), eZStringType\validateClassAttributeHTTPInput(), eZFloatType\validateClassAttributeHTTPInput(), eZIntegerType\validateClassAttributeHTTPInput(), eZOptionType\validateCollectionAttributeHTTPInput(), eZBooleanType\validateCollectionAttributeHTTPInput(), eZTextType\validateCollectionAttributeHTTPInput(), eZEmailType\validateCollectionAttributeHTTPInput(), eZTimeType\validateCollectionAttributeHTTPInput(), eZStringType\validateCollectionAttributeHTTPInput(), eZDateType\validateCollectionAttributeHTTPInput(), eZDateTimeType\validateCollectionAttributeHTTPInput(), eZSelectionType\validateCollectionAttributeHTTPInput(), eZIntegerType\validateCollectionAttributeHTTPInput(), eZCountryType\validateCollectionAttributeHTTPInput(), validateCurrencyData(), eZDateTimeValidator\validateDate(), eZDateTimeValidator\validateDateTime(), eZDateType\validateDateTimeHTTPInput(), eZDateTimeType\validateDateTimeHTTPInput(), eZEmailType\validateEMailHTTPInput(), eZApproveType\validateGroupIDList(), eZApproveType\validateHTTPInput(), eZSimplifiedXMLInput\validateInput(), eZXMLInputHandler\validateInput(), eZContentObject\validateInput(), eZIntegerType\validateIntegerHTTPInput(), eZAuthorType\validateObjectAttributeHTTPInput(), eZRangeOptionType\validateObjectAttributeHTTPInput(), eZISBNType\validateObjectAttributeHTTPInput(), eZPriceType\validateObjectAttributeHTTPInput(), eZMatrixType\validateObjectAttributeHTTPInput(), eZMultiPriceType\validateObjectAttributeHTTPInput(), eZObjectRelationListType\validateObjectAttributeHTTPInput(), eZObjectRelationType\validateObjectAttributeHTTPInput(), eZTimeType\validateObjectAttributeHTTPInput(), eZProductCategoryType\validateObjectAttributeHTTPInput(), eZDateType\validateObjectAttributeHTTPInput(), eZMultiOptionType\validateObjectAttributeHTTPInput(), eZIniSettingType\validateObjectAttributeHTTPInput(), eZUserType\validateObjectAttributeHTTPInput(), eZOptionType\validateObjectAttributeHTTPInput(), eZBooleanType\validateObjectAttributeHTTPInput(), eZEmailType\validateObjectAttributeHTTPInput(), eZKeywordType\validateObjectAttributeHTTPInput(), eZTextType\validateObjectAttributeHTTPInput(), eZURLType\validateObjectAttributeHTTPInput(), eZDateTimeType\validateObjectAttributeHTTPInput(), eZStringType\validateObjectAttributeHTTPInput(), eZFloatType\validateObjectAttributeHTTPInput(), eZIntegerType\validateObjectAttributeHTTPInput(), eZSelectionType\validateObjectAttributeHTTPInput(), eZMediaType\validateObjectAttributeHTTPInput(), eZCountryType\validateObjectAttributeHTTPInput(), eZEnumType\validateObjectAttributeHTTPInput(), eZImageType\validateObjectAttributeHTTPInput(), eZBinaryFileType\validateObjectAttributeHTTPInput(), eZStringType\validateStringHTTPInput(), eZDateTimeValidator\validateTime(), eZTimeType\validateTimeHTTPInput(), and eZApproveType\validateUserIDList().