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
显示文件 Open project: pradosoft/prado Class Usage Examples

Public Methods

Method 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 )

Protected Methods

Method 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 method

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

getCharset() public method

public getCharset ( ) : string
return string charset for string length comparison.

getClientClassName() protected method

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

getClientScriptOptions() protected method

Returns an array of javascript validator options.
protected getClientScriptOptions ( ) : array
return array javascript validator options.

getDataType() public method

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

getDateFormat() public method

public getDateFormat ( ) : string
return string the date validation date format if any

getMaxValue() public method

public getMaxValue ( ) : string
return string the maximum value of the validation range.

getMinValue() public method

public getMinValue ( ) : string
return string the minimum value of the validation range.

getStrictComparison() public method

public getStrictComparison ( ) : boolean
return boolean true to perform strict comparison.

isGreaterThan() protected method

protected isGreaterThan ( $left, $right )

isLessThan() protected method

protected isLessThan ( $left, $right )

isValidDate() protected method

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

isValidFloat() protected method

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

isValidInteger() protected method

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

isValidString() protected method

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

isValidStringLength() protected method

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

setCharset() public method

public setCharset ( $value )

setDataType() public method

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

setDateFormat() public method

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

setMaxValue() public method

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

setMinValue() public method

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

setStrictComparison() public method

public setStrictComparison ( $value )