2017 © Pedro Peláez
 

cakephp-plugin validation

Extra validation providers and rules for CakePHP 3

image

gourmet/validation

Extra validation providers and rules for CakePHP 3

  • Wednesday, April 20, 2016
  • by jadb
  • Repository
  • 3 Watchers
  • 5 Stars
  • 2,898 Installations
  • PHP
  • 0 Dependents
  • 1 Suggesters
  • 3 Forks
  • 1 Open issues
  • 3 Versions
  • 10 % Grown

The README.md

Validation

Build Status Total Downloads License, (*1)

Extra validation providers and rules for CakePHP 3, (*2)

Install

Using Composer:, (*3)

composer require gourmet/validation:~1.0

This plugin does not require to be loaded in bootstrap as it only uses autoloaded classes., (*4)

Usage

In any table's validationDefault() method:, (*5)

public function validationDefault(Validator $validator)
{
    $validator
        ->provider('respect', new \Gourmet\Validation\Validation\RespectProvider())
        ->provider('iso', new \Gourmet\Validation\Validation\IsoCodesProvider())

        ->add('country_code', 'valid', [
            'provider' => 'respect',
            'rule' => 'countryCode',
        ])

        ->add('zip_code_by_country_code', 'valid', [
            'rule' => function($value, $context) {
                $provider = $context['providers']['respect'];
                $country = $context['data']['country_code'];
                return $provider->__call('postalCode', [$value, $country]);
            }
        ])

        ->add('zip_code_by_country', 'valid', [
            'rule' => function($value, $context) {
                $provider = $context['providers']['iso'];
                $country = $context['data']['country'];
                return $provider->__call('zip_code', [$value, $country]);
            }
        ])

        ->add('book_code', 'valid', [
            'provider' => 'iso',
            'rule' => 'isbn10'
        ])
}

For more, check out the supported validation methods for each of the official libraries the providers proxy:, (*6)

Patches & Features

  • Fork
  • Mod, fix
  • Test - this is important, so it's not unintentionally broken
  • Commit - do not mess with license, todo, version, etc. (if you do change any, bump them into commits of their own that I can ignore when I pull)
  • Pull request - bonus point for topic branches

Bugs & Feedback

http://github.com/gourmet/validation/issues, (*7)

License

Copyright (c) 2015, Jad Bitar and licensed under The MIT License., (*8)

The Versions

20/04 2016

dev-master

9999999-dev https://github.com/gourmet/validation

Extra validation providers and rules for CakePHP 3

  Sources   Download

MIT

The Requires

 

The Development Requires

cakephp gourmet

24/04 2015

v1.0.1

1.0.1.0 https://github.com/gourmet/validation

Extra validation providers and rules for CakePHP 3

  Sources   Download

MIT

The Requires

 

The Development Requires

cakephp gourmet

27/03 2015

v1.0.0

1.0.0.0 https://github.com/gourmet/validation

Extra validation providers and rules for CakePHP 3

  Sources   Download

MIT

The Requires

 

The Development Requires

cakephp gourmet