PHP code example of oligriffiths / validation-component

1. Go to this page and download the library: Download oligriffiths/validation-component library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

oligriffiths / validation-component example snippets


protected function _initialize(\Nooku\Library\Config $config)
{
    $config->append(array(
        'behaviors' => array(
            'com:validation.database.behavior.validatable'
        )
    ))
}

protected function _initialize(\Nooku\Library\Config $config)
{
    $config->append(array(
        'behaviors' => array(
            'com:validation.database.behavior.validatable' => array(
                'constraints' => array(
                    'password' => array('md5')
                )
            )
        )
    ))
}

protected function _initialize(\Nooku\Library\Config $config)
{
    $config->append(array(
        'behaviors' => array(
            'com:validation.controller.behavior.validatable'
        )
    ))
}

$this->getObject('com:validation.constraint.email')->validate('[email protected]');

$valid = $this->getObject('com:validation.constraint.email')->isValid('[email protected]');

$set = $this->getObject('com:validation.constraint.set', array(
    'constraints' => array(
        'com:validation.constraint.email',
        'com:validation.constraint.length' => array('min' => 0, 'max' => 150)
    )
));

$valid = $set->validate('[email protected]');
$errors = $set->getErrors();

$set = $this->getObject('com:validation.validator.set',
    array('constraints' =>
        'email' => array('com:validation.constraint.email'),
        'name' => array('com:validation.constraint.length' => array('min' => 0, 'max' => 150))
    )
));

$valid = $set->validate(array('email' => '[email protected]', 'name' => 'Jon Doe'));
$errors = $set->getErrors();