Validator factory

package CONTENIDO Validator

 Methods

Instantiates and returns the validator.

getInstance(string $validator, array $options) : \cValidatorAbstract
Static

Sets also validators default options.

Each validator can be configured thru CONTENIDO $cfg configuration variable. Example for email validator:

$cfg['validator']['email'] = array(
    // List of top level domains to disallow
    'disallow_tld' => array('.test', '.example', '.invalid', '.localhost'),
    // List of hosts to disallow
    'disallow_host' => array('example.com', 'example.org', 'example.net'),
    // Flag to check DNS records for MX type
    'mx_check' => false,
);

Parameters

$validator

string

Validator to get

$options

array

Options to use for the validator. Any passed option overwrites the related option in global validator configuration.

Exceptions

\cInvalidArgumentException If type of validator is unknown or not available

Returns