2017 © Pedro Peláez
 

library php-validation

php validation library

image

quantumunit/php-validation

php validation library

  • Tuesday, July 5, 2016
  • by dmeikle
  • Repository
  • 1 Watchers
  • 0 Stars
  • 202 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

php-validation

my first crack at learning PHP back in 2007. Rewritten in 2014 to use YAML instead of XML. Changed from Chain of Command pattern to use basic Load-On-Demand instead., (*1)

Usage:

$loader = new YamlConfiguration();
$loader->loadConfig(__SITE_PATH . '/validation-config.yml');, (*2)

//YAML key $key = 'new_user_signup'; $validator = new Validator($loader, $this->getLogger()); //Monolog\Logger, (*3)

$result = $validator->validateRequest($key, $this->getPostedParams());, (*4)

Notes:

if $result is an array holding values, it will be an associative array where the fieldname is the index key and the LANG_STRING (for multi-locale support) is the value of that index., (*5)

sample YAML config (validation-config.yml):, (*6)

failkey: some_other_yml_key, (*7)

fields:, (*8)

uses 2 validation routines in this example, Required then String

- firstname:
    - 
        class: Required      
        failkey: VALIDATION_REQUIRED_FIELD
    - 
        class: String    
        failkey: VALIDATION_INVALID_STRING
        params:
            maxlength: 20

- lastname:
    - 
        class: Required       
        failkey: VALIDATION_REQUIRED_FIELD         
    - 
        class: String
        failkey: VALIDATION_INVALID_STRING
        params:
            maxlength: 20

email is optional in this sample so no Required validation needed

- email
    -
        class: Email
        failkey: VALIDATION_INVALID_EMAIL

Possible Validation Classes:, (*9)

Address

AlphaNumeric - letters and numbers only

Alphabet    - letters only

BusinessName - letters, numbers, apostrophe, and &()-,.

Currency

Date

Email

IPAddress

Integer

Required

String - letters, spaces and apostrophes

Telephone

URL

The Versions

05/07 2016

dev-master

9999999-dev https://github.com/dmeikle/php-validation

php validation library

  Sources   Download

MIT

The Requires

 

The Development Requires

php validation

19/11 2014

dev-master2

dev-master2 https://github.com/dmeikle/php-validation

php validation library

  Sources   Download

MIT

The Requires

 

The Development Requires

php validation