Zend\Validator\InArray
Synopsis
class InArray
extends AbstractValidator
{
- // constants
- const NOT_IN_ARRAY = 'notInArray';
- const COMPARE_STRICT = 1;
- const COMPARE_NOT_STRICT_AND_PREVENT_STR_TO_INT_VULNERABILITY = 0;
- const COMPARE_NOT_STRICT = 1;
- // members
- protected array $messageTemplates;
- protected array $haystack;
- protected int $strict;
- protected bool $recursive;
- // Inherited members from AbstractValidator
- protected mixed $value;
- protected TranslatorInterface $defaultTranslator;
- protected string $defaultTranslatorTextDomain;
- protected integer $messageLength;
- protected array $abstractOptions;
- // methods
- public mixed getHaystack()
- public InArray setHaystack()
- public bool|int getStrict()
- public InArray setStrict()
- public bool getRecursive()
- public InArray setRecursive()
- public bool isValid()
- // Inherited methods from AbstractValidator
- public void __construct()
- public mixed getOption()
- public array getOptions()
- public AbstractValidator setOptions()
- public array getMessages()
- public bool __invoke()
- public array getMessageVariables()
- public array getMessageTemplates()
- public AbstractValidator setMessage()
- public AbstractValidator setMessages()
- public mixed __get()
- protected string createMessage()
- protected void error()
- protected mixed getValue()
- protected void setValue()
- public AbstractValidator setValueObscured()
- public bool isValueObscured()
- public AbstractValidator setTranslator()
- public TranslatorInterface|null getTranslator()
- public bool hasTranslator()
- public AbstractValidator setTranslatorTextDomain()
- public string getTranslatorTextDomain()
- public static void setDefaultTranslator()
- public static TranslatorInterface|null getDefaultTranslator()
- public static bool hasDefaultTranslator()
- public static void setDefaultTranslatorTextDomain()
- public static string getDefaultTranslatorTextDomain()
- public AbstractValidator setTranslatorEnabled()
- public bool isTranslatorEnabled()
- public static int getMessageLength()
- public static void setMessageLength()
- protected string translateMessage()
Hierarchy
Extends
Constants
Name | Value |
---|---|
NOT_IN_ARRAY | 'notInArray' |
COMPARE_STRICT | 1 |
COMPARE_NOT_STRICT_AND_PREVENT_STR_TO_INT_VULNERABILITY | 0 |
COMPARE_NOT_STRICT | 1 |
Members
protected
- $abstractOptions
- $defaultTranslator
—
Zend\Validator\Translator\TranslatorInterface
Default translation object for all validate objects - $defaultTranslatorTextDomain
—
string
Default text domain to be used with translator - $haystack
—
array
Haystack of possible values - $messageLength
—
int
Limits the maximum returned length of an error message - $messageTemplates — array
- $recursive
—
Zend\Validator\bool
Whether a recursive search should be done - $strict
—
int
Type of strict check to be used. Due to "foo" == 0 === TRUE with in_array when strict = false, an option has been added to prevent this. When $strict = 0/false, the most secure non-strict check is implemented. if $strict = -1, the default in_array non-strict behaviour is used - $value
—
mixed
The value to be validated
Methods
public
- getHaystack() — Returns the haystack option
- getRecursive() — Returns the recursive option
- getStrict() — Returns the strict option
- isValid() — Returns true if and only if $value is contained in the haystack option. If the strict option is true, then the type of $value is also checked.
- setHaystack() — Sets the haystack option
- setRecursive() — Sets the recursive option
- setStrict() — Sets the strict option mode InArray::CHECK_STRICT | InArray::CHECK_NOT_STRICT_AND_PREVENT_STR_TO_INT_VULNERABILITY | InArray::CHECK_NOT_STRICT
Inherited from Zend\Validator\AbstractValidator
protected
- createMessage() — Constructs and returns a validation failure message with the given message key and value.
- error()
- getValue() — Returns the validation value
- setValue() — Sets the value to be validated and clears the messages and errors arrays
- translateMessage() — Translate a validation message
public
- __get() — Magic function returns the value of the requested property, if and only if it is the value or a message variable.
- __invoke() — Invoke as command
- getDefaultTranslator() — Get default translation object for all validate objects
- getDefaultTranslatorTextDomain() — Get default translation text domain for all validate objects
- getMessageLength() — Returns the maximum allowed message length
- getMessageTemplates() — Returns the message templates from the validator
- getMessageVariables() — Returns an array of the names of variables that are used in constructing validation failure messages
- getMessages() — Returns array of validation failure messages
- getOption() — Returns an option
- getOptions() — Returns all available options
- getTranslator() — Return translation object
- getTranslatorTextDomain() — Return the translation text domain
- hasDefaultTranslator() — Is there a default translation object set?
- hasTranslator() — Does this validator have its own specific translator?
- isTranslatorEnabled() — Is translation enabled?
- isValueObscured() — Retrieve flag indicating whether or not value should be obfuscated in messages
- setDefaultTranslator() — Set default translation object for all validate objects
- setDefaultTranslatorTextDomain() — Set default translation text domain for all validate objects
- setMessage() — Sets the validation failure message template for a particular key
- setMessageLength() — Sets the maximum allowed message length
- setMessages() — Sets validation failure message templates given as an array, where the array keys are the message keys, and the array values are the message template strings.
- setOptions() — Sets one or multiple options
- setTranslator() — Set translation object
- setTranslatorEnabled() — Indicate whether or not translation should be enabled
- setTranslatorTextDomain() — Set translation text domain
- setValueObscured() — Set flag indicating whether or not value should be obfuscated in messages