PHP code example of ylab / validation

1. Go to this page and download the library: Download ylab/validation 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/ */

    

ylab / validation example snippets


$this->oValidator = ValidatorHelper::makeCustomValidator([], $this->rules(), $sFile, LANGUAGE_ID);

/**
 * При необходимости в компоненте можно реализовать дополнительные правила валидации, например, данный валидатор 
 * проверяет наличие пользователя в базе данных по ID.
 */
$this->oValidator->addExtension('user_exists', function($attribute, $value, $parameters, $validator) {
    $arValidate = UserTable::getList([
        'select' => ['ID'],
        'filter' => ['=ID' => $value],
        'limit' => 1
    ])->fetch();

    return $arValidate['ID'] ? true : false;
});