PHP code example of tiny-talk-messages / validation

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

    

tiny-talk-messages / validation example snippets


use TinyTalkMessages\Validation\Data\ErrorField;
use TinyTalkMessages\Validation\Data\Errors;

$errors = new Errors();
$errors->add(new ErrorField('email', 'This value is not a valid email.'));
$errors->add(new ErrorField('password', 'Password is too short.'));

// Handle errors
if (count($errors) > 0) {
    foreach ($errors as $error) {
        echo $error->field . ': ' . $error->message . PHP_EOL;
    }
}

src/
  Data/
    ErrorField.php         # Field-specific validation error
    Errors.php             # Error collection class
  Interfaces/
    RuleInterface.php      # Interface for custom rules
    ValidatorInterface.php # Interface for validators
examples/                  # Implementation examples
  hooked-rule-validation.php
  rules.php
  validator.php