PHP Class Prado\Web\UI\WebControls\TRangeValidator

TRangeValidator tests whether an input value is within a specified range. TRangeValidator uses three key properties to perform its validation. The {@link setMinValue MinValue} and {@link setMaxValue MaxValue} properties specify the minimum and maximum values of the valid range. The {@link setDataType DataType} property is used to specify the data type of the value and the minimum and maximum range values. These values are converted to this data type before the validation operation is performed. The following value types are supported: - Integer A 32-bit signed integer data type. - Float A double-precision floating point number data type. - Date A date data type. The date format can be specified by setting {@link setDateFormat DateFormat} property, which must be recognizable by {@link TSimpleDateFormatter}. If the property is not set, the GNU date syntax is assumed. - String A string data type. - StringLength check for string length. If {@link setStrictComparison StrictComparison} is true, then the ranges are compared as strictly less than the max value and/or strictly greater than the min value. The TRangeValidator allows a special DataType "StringLength" that can be used to verify minimum and maximum string length. The {@link setCharset Charset} property can be used to force a particular charset for comparison. Otherwise, the application charset is used and is defaulted as UTF-8.
Since: 3.0
Author: Qiang Xue ([email protected])
Inheritance: extends TBaseValidator
Afficher le fichier Open project: pradosoft/prado Class Usage Examples

Méthodes publiques

Méthode Description
getCharset ( ) : string
getDataType ( ) : TRangeValidationDataType
getDateFormat ( ) : string
getMaxValue ( ) : string
getMinValue ( ) : string
getStrictComparison ( ) : boolean
setCharset ( $value )
setDataType ( $value ) Sets the data type that the values being compared are converted to before the comparison is made.
setDateFormat ( $value ) Sets the date format for a date validation
setMaxValue ( $value ) Sets the maximum value of the validation range.
setMinValue ( $value ) Sets the minimum value of the validation range.
setStrictComparison ( $value )

Méthodes protégées

Méthode Description
evaluateIsValid ( ) : boolean This method overrides the parent's implementation.
getClientClassName ( ) : string Gets the name of the javascript class responsible for performing validation for this control.
getClientScriptOptions ( ) : array Returns an array of javascript validator options.
isGreaterThan ( $left, $right )
isLessThan ( $left, $right )
isValidDate ( $value ) : boolean Determine if the date is within the specified range.
isValidFloat ( $value ) : boolean Determine if the value is within the specified float range.
isValidInteger ( $value ) : boolean Determine if the value is within the integer range.
isValidString ( $value ) : boolean Compare the string with a minimum and a maxiumum value.
isValidStringLength ( $value ) : boolean

Method Details

evaluateIsValid() protected méthode

The validation succeeds if the input data is within the range. The validation always succeeds if the input data is empty.
protected evaluateIsValid ( ) : boolean
Résultat boolean whether the validation succeeds

getCharset() public méthode

public getCharset ( ) : string
Résultat string charset for string length comparison.

getClientClassName() protected méthode

This method overrides the parent implementation.
protected getClientClassName ( ) : string
Résultat string the javascript class name

getClientScriptOptions() protected méthode

Returns an array of javascript validator options.
protected getClientScriptOptions ( ) : array
Résultat array javascript validator options.

getDataType() public méthode

public getDataType ( ) : TRangeValidationDataType
Résultat TRangeValidationDataType the data type that the values being compared are converted to before the comparison is made. Defaults to TRangeValidationDataType::String.

getDateFormat() public méthode

public getDateFormat ( ) : string
Résultat string the date validation date format if any

getMaxValue() public méthode

public getMaxValue ( ) : string
Résultat string the maximum value of the validation range.

getMinValue() public méthode

public getMinValue ( ) : string
Résultat string the minimum value of the validation range.

getStrictComparison() public méthode

public getStrictComparison ( ) : boolean
Résultat boolean true to perform strict comparison.

isGreaterThan() protected méthode

protected isGreaterThan ( $left, $right )

isLessThan() protected méthode

protected isLessThan ( $left, $right )

isValidDate() protected méthode

Uses pradoParseDate and strtotime to get the date from string.
protected isValidDate ( $value ) : boolean
Résultat boolean true if within range.

isValidFloat() protected méthode

Determine if the value is within the specified float range.
protected isValidFloat ( $value ) : boolean
Résultat boolean true if within range.

isValidInteger() protected méthode

Determine if the value is within the integer range.
protected isValidInteger ( $value ) : boolean
Résultat boolean true if within integer range.

isValidString() protected méthode

Uses strcmp for comparision.
protected isValidString ( $value ) : boolean
Résultat boolean true if the string is within range.

isValidStringLength() protected méthode

protected isValidStringLength ( $value ) : boolean
Résultat boolean true if min and max string length are satisfied.

setCharset() public méthode

public setCharset ( $value )

setDataType() public méthode

Sets the data type that the values being compared are converted to before the comparison is made.
public setDataType ( $value )

setDateFormat() public méthode

Sets the date format for a date validation
public setDateFormat ( $value )

setMaxValue() public méthode

Sets the maximum value of the validation range.
public setMaxValue ( $value )

setMinValue() public méthode

Sets the minimum value of the validation range.
public setMinValue ( $value )

setStrictComparison() public méthode

public setStrictComparison ( $value )