print utilityValidateEqual

Validates that a variable is equal to a preset value for example the entered Captcha code is the same as the stored captcha code.

Note: this validator checks for a value not identity. To check if an object or array is exactly equal (identity) use utilityValidateIdentical.

Note: this validator cannot be used with arrays, objects or resources.

// validates that the int 12 equals the string "12"
$oValidator = new utilityValidateEqual(
    array(
        utilityValidateEqual::TEST_VALUE => '12',
    )
);
if ( $oValidator->isValid(12) ) {
    // is valid, because 12 and '12' are equal
}

You may get un-expected behaviour if you use this validator to compare integers and strings. PHP will auto-convert an integer to a string representation (or vice-versa) so (as in the example) 12 does equal "12". Consider utilityValidateIdentical if you require both type and value to match, or use utilityValidateRegex.


Methods


Inherited Methods

<  1  >