-
addMessage ($name, $value)
$name |
The error code |
$value |
The error message |
Adds a new error code with a default error message.
-
addOption ($name, $value)
$name |
The option name |
$value |
The default value |
Adds a new option value with a default value.
-
addRequiredOption ($name)
Adds a required option.
-
(string) asString ($indent)
$indent |
Indentation (number of spaces before each line) |
Returns a string representation of this validator.
returns The string representation of the validator
-
(mixed) clean ($value)
Cleans the input value.
This method is also responsible for trimming the input value
and checking the required option.
returns The cleaned value
throws sfValidatorError
-
configure ($options, $messages)
$options |
An array of options |
$messages |
An array of error messages |
Configures the current validator.
This method allows each validator to add options and error messages
during validator creation.
If some options and messages are given in the sfValidatorBase constructor
they will take precedence over the options and messages you configure
in this method.
-
(mixed) doClean ($value)
Cleans the input value.
Every subclass must implements this method.
returns The cleaned value
throws sfValidatorError
-
(string) getCharset ()
Returns the charset to use when validating strings.
returns The charset (default to UTF-8)
-
(array) getDefaultMessages ()
Returns default messages for all possible error codes.
returns An array of default error codes and messages
-
(array) getDefaultOptions ()
Returns default option values.
returns An array of default option values
-
(mixed) getEmptyValue ()
Returns an empty value for this validator.
returns The empty value for this validator
-
(array) getErrorCodes ()
Returns an array of all error codes for this validator.
returns An array of possible error codes
-
(string) getMessage ($name)
Returns an error message given an error code.
returns The error message, or the empty string if the error code does not exist
-
(array) getMessages ()
Returns an array of current error messages.
returns An array of messages
-
(string) getMessagesWithoutDefaults ()
Returns all error messages with non default values.
returns A string representation of the error messages
-
(mixed) getOption ($name)
Gets an option value.
returns The option value
-
(array) getOptions ()
Returns all options.
returns An array of options
-
(string) getOptionsWithoutDefaults ()
Returns all options with non default values.
returns A string representation of the options
-
getRequiredOptions ()
Returns all required option names.
-
(bool) hasOption ($name)
Returns true if the option exists.
returns true if the option exists, false otherwise
-
(bool) isEmpty ($value)
Returns true if the value is empty.
returns true if the value is empty, false otherwise
-
setCharset ($charset)
Sets the charset to use when validating strings.
-
setDefaultMessages ($messages)
$messages |
An array of default error codes and messages |
Sets default messages for all possible error codes.
-
setDefaultOptions ($options)
$options |
An array of default option values |
Sets default option values.
-
setMessage ($name, $value)
$name |
The error code |
$value |
The error message |
Changes an error message given the error code.
-
setMessages ($values)
$values |
An array of error messages |
Changes all error messages.
-
setOption ($name, $value)
$name |
The option name |
$value |
The value |
Changes an option value.
-
setOptions ($values)
$values |
An array of options |
Changes all options.
-
__construct ($options, $messages)
$options |
An array of options |
$messages |
An array of error messages |
Constructor.
Available options:
* required: true if the value is required, false otherwise (default to true)
* trim: true if the value must be trimmed, false otherwise (default to false)
* empty_value: empty value when value is not required
Available error codes:
* required
* invalid