An exception caused by a data not matching a rule or set of rules
|1.0.0b4||Added support for nested error arrays 10/3/10|
|1.0.0b3||Added removeFieldNames() 5/26/10|
|1.0.0b2||Added a custom __construct() to handle arrays of messages 9/17/09|
|1.0.0b||The initial implementation 6/14/07|
The formatting string to use for field names
Accepts a field name and formats it based on the formatting string set via setFieldFormat()
string formatField( string $field )
|string||$field||The name of the field to format|
The formatted field name
Removes the field names from normal validation messages, leaving just the message part
array removeFieldNames( array $messages )
|array||$messages||The messages to remove the field names from|
The messages without field names
Set the format to be applied to all field names used in fValidationExceptions
The format should contain exactly one %s sprintf() conversion specification, which will be replaced with the field name. Any literal % characters should be written as %%.
The default format is just %s: , which simply inserts a : and space after the field name.
void setFieldFormat( string $format )
|string||$format||A string to format the field name with - %s will be replaced with the field name|
Sets the message for the exception, allowing for custom formatting beyond fException
If this method receives exactly two parameters, a string and an array, the string will be used as a message in a HTML <p> tag and the array will be turned into an unorder list <ul> tag with each element in the array being an <li> tag. It is possible to pass an optional exception code as a third parameter.
The following PHP:
throw new fValidationException( 'The following problems were found:', array( 'Please provide your name', 'Please provide your email address' ) );
Would create the message:
The following problems were found:
- Please provide your name
- Please provide your email address
If the parameters are anything else, they will be passed to fException::__construct().
fException __construct( string $message='', array $sub_messages, mixed $code )
|string||$message||The beginning message for the exception. This will be placed in a <p> tag.|
|array||$sub_messages||An array of strings to place in a <ul> tag|
|mixed||$code||The optional exception code|