void addNormalization(
string
$field, string
$method
)
|
|
Add a normalization to a field
Parameters:
|
string |
$field: |
|
|
string |
$method: |
A class method or a function to use |
API Tags:
void addValidation(
string
$field, string
$method, [string
$message = 'Failed validation']
)
|
|
Add a validation to a field
Parameters:
|
string |
$field: |
|
|
string |
$method: |
A class method or a function to use |
|
string |
$message: |
Optional; error message to display on failed validation |
API Tags:
Information Tags:
| Throws: | Phly_InputFilter_Exception if method is not a valid method or function |
float castFloat(
mixed
$value
)
|
|
cast a value to a float
Parameters:
API Tags:
int castInt(
mixed
$value
)
|
|
cast a value to an integer
Parameters:
API Tags:
string castString(
mixed
$value
)
|
|
cast a value to a string
Parameters:
API Tags:
mixed config(
string
$key, mixed
$value
)
|
|
Configuration
Allows storing/retrieving values for use in validations and normalizations.
Passing no values returns the entire $_config.
Passing a single string value returns the value associated with that key in $_config.
Passing two values associates the second value with the key specified in the first in $_config.
If all else fails, returns null.
Parameters:
|
string |
$key: |
Optional; configuration key |
|
mixed |
$value: |
Optional; value to store in $key |
API Tags:
Retrieve a list of key => error message pairs
Retrieves a list of key => array of error messages.
API Tags:
mixed getParam(
string
$key
)
|
|
Return a parameter from the $_params list
Parameters:
API Tags:
string htmlSafe(
string
$value
)
|
|
Make a string HTML safe
Parameters:
API Tags:
boolean isBoolean(
mixed
$value
)
|
|
Value is boolean
Tests for various flavors of boolean:
- 'Y' or 'N' (case insenstitive; also 'yes' and 'no')
- true or false
- 'T' or 'F' (case insentitive; also 'true' and 'false')
- 0 or 1
Parameters:
API Tags:
boolean isBooleanInt(
mixed
$value
)
|
|
Check if an integer value is a boolean (0 or 1)
Parameters:
API Tags:
boolean isEmail(
string
$value
)
|
|
Validate an email address
Parameters:
API Tags:
boolean isNotZero(
mixed
$value
)
|
|
Value is not zero
Parameters:
API Tags:
boolean isPercent(
mixed
$value
)
|
|
value is a percentage
Parameters:
API Tags:
boolean isPositive(
mixed
$value
)
|
|
Value is positive
Parameters:
API Tags:
boolean isUrl(
string
$value
)
|
|
Validate a URL
Parameters:
API Tags:
true noValidate(
mixed
$value
)
|
|
Dummy validation
Parameters:
API Tags:
boolean required(
mixed
$value
)
|
|
Value required
Parameters:
API Tags:
array|false run(
mixed
$array
)
|
|
Run filters and normalizations
Loops through each key in $array, using only those registered in addValidation() and/or addNormalization().
Returns array of clean variables, or false on validation error. Error messages may be retrieved using getErrors().
Note: Only variables that have validations are run through normalizations; if you wish to normalize a variable without validating it, add an 'noValidate' validation to the field.
API Tags:
Information Tags:
| Throws: | Phly_InputFilter_Exception |
void setParam(
string
$key, mixed
$value
)
|
|
Set a parameter in the $_params list
Parameters:
|
string |
$key: |
|
|
mixed |
$value: |
|
API Tags:
boolean _isError(
string
$field
)
|
|
Determine if a field has validation errors
Parameters:
API Tags:
mixed _normalize(
string
$field, mixed
$value
)
|
|
Normalize a field's value
Run normalizations on a field. Normalizations are run in the order in which they are registered.
Parameters:
|
string |
$field: |
|
|
mixed |
$value: |
|
API Tags:
void _pushError(
string
$field, string
$message
)
|
|
Push an error on to a field's error stack
Parameters:
|
string |
$field: |
|
|
string |
$message: |
|
API Tags:
null|boolean _validate(
string
$field, mixed
$value
)
|
|
Validate a field against a value
Parameters:
|
string |
$field: |
|
|
mixed |
$value: |
|
API Tags:
| Return: | Returns boolean success or failure; returns null if key has no validations associated |
| Access: | protected |