Exponential 6.0.13 Exponential Enterprise Open Source CMS - PHP Class Reference

Public Member Functions | Public Attributes | List of all members
eZInputValidator Class Reference

Input text validation and correction. More...

Inheritance diagram for eZInputValidator:

## Public Member Functions
| validate ( $text)
| fixup ( $text)

## Public Attributes
const | STATE_ACCEPTED = 1
const | STATE_INTERMEDIATE = 2
const | STATE_INVALID = 3

## Detailed Description

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 )
{
}
}
eZInputValidator\STATE_ACCEPTED
const STATE_ACCEPTED
Definition: ezinputvalidator.php:79
eZInputValidator\STATE_INVALID
const STATE_INVALID
Definition: ezinputvalidator.php:81
eZInputValidator\fixup
fixup( $text)
Definition: ezinputvalidator.php:99
eZInputValidator\validate
validate( $text)
Definition: ezinputvalidator.php:90

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" );
}
}
eZInputValidator\STATE_INTERMEDIATE
const STATE_INTERMEDIATE
Definition: ezinputvalidator.php:80

Definition at line 77 of file ezinputvalidator.php.

## Member Function Documentation

## ◆ fixup()

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 eZRegExpValidator, eZIntegerValidator, and eZFloatValidator.

Definition at line 99 of file ezinputvalidator.php.

## ◆ validate()

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 eZRegExpValidator, eZIntegerValidator, eZFloatValidator, and eZFileExtensionBlackListValidator.

Definition at line 90 of file ezinputvalidator.php.

References STATE_ACCEPTED.

## Member Data Documentation

## ◆ STATE_ACCEPTED

const eZInputValidator::STATE_ACCEPTED = 1

Definition at line 79 of file ezinputvalidator.php.

Referenced by eZBinaryFileType\fetchObjectAttributeHTTPInput(), eZISBNType\fetchObjectAttributeHTTPInput(), eZMediaType\fetchObjectAttributeHTTPInput(), eZDataType\fixupClassAttributeHTTPInput(), eZFileExtensionBlackListValidator\validate(), eZFloatValidator\validate(), validate(), eZIntegerValidator\validate(), eZRegExpValidator\validate(), eZMultiOption2Type\validateAddToBasket(), eZDataType\validateAddToBasket(), eZKeywordType\validateClassAttributeHTTPInput(), eZFloatType\validateClassAttributeHTTPInput(), eZIdentifierType\validateClassAttributeHTTPInput(), eZIniSettingType\validateClassAttributeHTTPInput(), eZIntegerType\validateClassAttributeHTTPInput(), eZMediaType\validateClassAttributeHTTPInput(), eZObjectRelationType\validateClassAttributeHTTPInput(), eZObjectRelationListType\validateClassAttributeHTTPInput(), eZStringType\validateClassAttributeHTTPInput(), eZURLType\validateClassAttributeHTTPInput(), eZDataType\validateClassAttributeHTTPInput(), eZEnumType\validateClassAttributeHTTPInput(), eZSelectionType\validateClassAttributeHTTPInput(), eZBooleanType\validateCollectionAttributeHTTPInput(), eZCountryType\validateCollectionAttributeHTTPInput(), eZDateType\validateCollectionAttributeHTTPInput(), eZDateTimeType\validateCollectionAttributeHTTPInput(), eZEmailType\validateCollectionAttributeHTTPInput(), eZIntegerType\validateCollectionAttributeHTTPInput(), eZSelectionType\validateCollectionAttributeHTTPInput(), eZStringType\validateCollectionAttributeHTTPInput(), eZTextType\validateCollectionAttributeHTTPInput(), eZTimeType\validateCollectionAttributeHTTPInput(), eZDataType\validateCollectionAttributeHTTPInput(), eZDateTimeValidator\validateDate(), eZDateTimeValidator\validateDateTime(), eZEmailType\validateEMailHTTPInput(), eZFloatType\validateFloatHTTPInput(), eZApproveType\validateGroupIDList(), eZWorkflowType\validateHTTPInput(), eZApproveType\validateHTTPInput(), eZContentObject\validateInput(), eZSimplifiedXMLInput\validateInput(), eZIntegerType\validateIntegerHTTPInput(), eZAuthorType\validateObjectAttributeHTTPInput(), eZBinaryFileType\validateObjectAttributeHTTPInput(), eZBooleanType\validateObjectAttributeHTTPInput(), eZCountryType\validateObjectAttributeHTTPInput(), eZDateType\validateObjectAttributeHTTPInput(), eZDateTimeType\validateObjectAttributeHTTPInput(), eZEmailType\validateObjectAttributeHTTPInput(), eZEnumType\validateObjectAttributeHTTPInput(), eZFloatType\validateObjectAttributeHTTPInput(), eZImageType\validateObjectAttributeHTTPInput(), eZIniSettingType\validateObjectAttributeHTTPInput(), eZIntegerType\validateObjectAttributeHTTPInput(), eZISBNType\validateObjectAttributeHTTPInput(), eZKeywordType\validateObjectAttributeHTTPInput(), eZMatrixType\validateObjectAttributeHTTPInput(), eZMediaType\validateObjectAttributeHTTPInput(), eZMultiOptionType\validateObjectAttributeHTTPInput(), eZMultiOption2Type\validateObjectAttributeHTTPInput(), eZMultiPriceType\validateObjectAttributeHTTPInput(), eZObjectRelationType\validateObjectAttributeHTTPInput(), eZObjectRelationListType\validateObjectAttributeHTTPInput(), eZOptionType\validateObjectAttributeHTTPInput(), eZPackageType\validateObjectAttributeHTTPInput(), eZPriceType\validateObjectAttributeHTTPInput(), eZProductCategoryType\validateObjectAttributeHTTPInput(), eZRangeOptionType\validateObjectAttributeHTTPInput(), eZSelectionType\validateObjectAttributeHTTPInput(), eZStringType\validateObjectAttributeHTTPInput(), eZTextType\validateObjectAttributeHTTPInput(), eZTimeType\validateObjectAttributeHTTPInput(), eZURLType\validateObjectAttributeHTTPInput(), eZUserType\validateObjectAttributeHTTPInput(), eZDataType\validateObjectAttributeHTTPInput(), eZStringType\validateStringHTTPInput(), eZDateTimeValidator\validateTime(), and eZApproveType\validateUserIDList().

## ◆ STATE_INTERMEDIATE

const eZInputValidator::STATE_INTERMEDIATE = 2

Definition at line 80 of file ezinputvalidator.php.

Referenced by eZFloatValidator\validate(), eZIntegerValidator\validate(), eZRegExpValidator\validate(), eZFloatType\validateClassAttributeHTTPInput(), eZIdentifierType\validateClassAttributeHTTPInput(), eZIntegerType\validateClassAttributeHTTPInput(), eZContentObject\validateInput(), eZIntegerType\validateIntegerHTTPInput(), eZBinaryFileType\validateObjectAttributeHTTPInput(), eZImageType\validateObjectAttributeHTTPInput(), eZMediaType\validateObjectAttributeHTTPInput(), and eZObjectRelationListType\validateObjectAttributeHTTPInput().

## ◆ STATE_INVALID

const eZInputValidator::STATE_INVALID = 3

Definition at line 81 of file ezinputvalidator.php.

Referenced by eZFileExtensionBlackListValidator\validate(), eZRegExpValidator\validate(), eZMultiOption2Type\validateAddToBasket(), eZFloatType\validateClassAttributeHTTPInput(), eZIdentifierType\validateClassAttributeHTTPInput(), eZIniSettingType\validateClassAttributeHTTPInput(), eZIntegerType\validateClassAttributeHTTPInput(), eZObjectRelationType\validateClassAttributeHTTPInput(), eZStringType\validateClassAttributeHTTPInput(), eZBooleanType\validateCollectionAttributeHTTPInput(), eZCountryType\validateCollectionAttributeHTTPInput(), eZDateType\validateCollectionAttributeHTTPInput(), eZDateTimeType\validateCollectionAttributeHTTPInput(), eZEmailType\validateCollectionAttributeHTTPInput(), eZIntegerType\validateCollectionAttributeHTTPInput(), eZOptionType\validateCollectionAttributeHTTPInput(), eZSelectionType\validateCollectionAttributeHTTPInput(), eZStringType\validateCollectionAttributeHTTPInput(), eZTextType\validateCollectionAttributeHTTPInput(), eZTimeType\validateCollectionAttributeHTTPInput(), eZDateTimeValidator\validateDate(), eZDateTimeValidator\validateDateTime(), eZDateType\validateDateTimeHTTPInput(), eZDateTimeType\validateDateTimeHTTPInput(), eZEmailType\validateEMailHTTPInput(), eZFloatType\validateFloatHTTPInput(), eZApproveType\validateGroupIDList(), eZApproveType\validateHTTPInput(), eZContentObject\validateInput(), eZXMLInputHandler\validateInput(), eZSimplifiedXMLInput\validateInput(), eZIntegerType\validateIntegerHTTPInput(), eZAuthorType\validateObjectAttributeHTTPInput(), eZBinaryFileType\validateObjectAttributeHTTPInput(), eZBooleanType\validateObjectAttributeHTTPInput(), eZCountryType\validateObjectAttributeHTTPInput(), eZDateType\validateObjectAttributeHTTPInput(), eZDateTimeType\validateObjectAttributeHTTPInput(), eZEmailType\validateObjectAttributeHTTPInput(), eZEnumType\validateObjectAttributeHTTPInput(), eZFloatType\validateObjectAttributeHTTPInput(), eZImageType\validateObjectAttributeHTTPInput(), eZIniSettingType\validateObjectAttributeHTTPInput(), eZIntegerType\validateObjectAttributeHTTPInput(), eZISBNType\validateObjectAttributeHTTPInput(), eZKeywordType\validateObjectAttributeHTTPInput(), eZMatrixType\validateObjectAttributeHTTPInput(), eZMediaType\validateObjectAttributeHTTPInput(), eZMultiOptionType\validateObjectAttributeHTTPInput(), eZMultiPriceType\validateObjectAttributeHTTPInput(), eZObjectRelationType\validateObjectAttributeHTTPInput(), eZObjectRelationListType\validateObjectAttributeHTTPInput(), eZOptionType\validateObjectAttributeHTTPInput(), eZPriceType\validateObjectAttributeHTTPInput(), eZProductCategoryType\validateObjectAttributeHTTPInput(), eZRangeOptionType\validateObjectAttributeHTTPInput(), eZSelectionType\validateObjectAttributeHTTPInput(), eZStringType\validateObjectAttributeHTTPInput(), eZTextType\validateObjectAttributeHTTPInput(), eZTimeType\validateObjectAttributeHTTPInput(), eZURLType\validateObjectAttributeHTTPInput(), eZUserType\validateObjectAttributeHTTPInput(), eZStringType\validateStringHTTPInput(), eZDateTimeValidator\validateTime(), eZTimeType\validateTimeHTTPInput(), and eZApproveType\validateUserIDList().

The documentation for this class was generated from the following file:

- ezinputvalidator.php

Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.