2017 © Pedro Peláez
 

library verja

An validation tool for arrays filled by foreign input

image

tflori/verja

An validation tool for arrays filled by foreign input

  • Sunday, April 15, 2018
  • by tflori
  • Repository
  • 1 Watchers
  • 2 Stars
  • 61 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 11 Versions
  • 5 % Grown

The README.md

tflori/verja

.github/workflows/push.yml Test Coverage Maintainability Latest Stable Version Total Downloads License, (*1)

TL;DR An validation tool for arrays filled by foreign input like forms, json data, query parameters etc. The name is from Old Norse language and means defender., (*2)

Installation

The usual way..., (*3)

composer require tflori/verja

Usage

Initialize a container, set the input data, define filters and validators, validate the data, get the data., (*4)

$gate = new Verja\Gate();
$gate->accepts([
    'username' => ['notEmpty', 'strLen:3:20'],
    'password' => ['notEmpty', 'strLen:8'],
    'email' => ['notEmpty', 'email'],
]);

if ($gate->validate($_POST)) {
  // how ever your orm works..
  $user = new User($gate->getData());
  $user->save();
} else {
  $errors = $gate->getErrors();
}

If you prefer auto completion you can of course pass objects:, (*5)

use Verja\Validator;

$gate->accepts([
    'username' => (new Field())
        ->addValidator(new Validator\NotEmpty())
        ->addValidator(new Validator\StrLen(3, 20)),
    'password' => [new Validator\NotEmpty(), new Validator\StrLen(8)],
    'email' => ['notEmpty', new App\Validator\DomainEmail('my-domain.com')]
]);

For more information check the documentation on github.io/verja., (*6)

Predefined Validators

In this library the following validators are included:, (*7)

  • After: Value must be a date time after $dateTime
  • Alpha: Value must contain only alphabetical characters
  • AlphaNumeric: Value must contain only alphabetic and numeric characters
  • Before: Value must be a date time before $dateTime
  • Boolean: Value must be boolean
  • Between: Value must be between $min and $max
  • Contains: Value must contain $subString
  • CreditCard: Value must be a valid credit card number
  • DateTime: Value must be a valid date in $format
  • EmailAddress: Value must be a valid email address
  • Equals: Field must match field $opposide
  • InArray: Value must exist in $array
  • Integer: Value must be integer
  • IpAddress: Value must be a valid IP address of $version
  • IsArray: Value must be an array
  • NotEmpty: Value must not be empty
  • Numeric: Value must be numeric
  • PregMatch: Value must match regular expression $pattern
  • Slug: Value must contain only slug characters (a-z, 0-9, -, _)
  • StrLen: String length from value must be between $min and $max
  • Truthful: Converted to boolean the value must be true
  • Url: Value must be a valid URL

Predefined Filters

The following filters are included in this library:, (*8)

  • Boolean: Converts integer and string values to boolean
  • ConvertCase: Converts case to $mode (upper, lower or title)
  • DateTime: Converts string from $format in DateTime object
  • Escape: Escape special characters for usage in html
  • Integer: Converts string values to integer
  • Numeric: Converts string values to float or integer
  • PregReplace: Replaces $pattern with $replace (replace can also be a callback)
  • Replace: Replaces $search in values with $replace
  • Trim: Trims $charcterMask from values

The Versions

15/04 2018

1.0.x-dev

1.0.9999999.9999999-dev

An validation tool for arrays filled by foreign input

  Sources   Download

MIT

The Requires

  • php ^7.0
  • ext-json *

 

The Development Requires

15/04 2018

v1.0.1

1.0.1.0

An validation tool for arrays filled by foreign input

  Sources   Download

MIT

The Requires

  • php ^7.0
  • ext-json *

 

The Development Requires

15/04 2018

dev-master

9999999-dev

An validation tool for arrays filled by foreign input

  Sources   Download

MIT

The Requires

  • php ^7.0
  • ext-json *

 

The Development Requires

15/04 2018

v1.1.0

1.1.0.0

An validation tool for arrays filled by foreign input

  Sources   Download

MIT

The Requires

  • php ^7.0
  • ext-json *

 

The Development Requires

06/04 2018

v1.0.0

1.0.0.0

An validation tool for arrays filled by foreign input

  Sources   Download

MIT

The Requires

  • php ^7.0
  • ext-json *

 

The Development Requires

06/04 2018

v1.0.0-rc.1

1.0.0.0-RC1

An validation tool for arrays filled by foreign input

  Sources   Download

MIT

The Requires

  • php ^7.0
  • ext-json *

 

The Development Requires

04/03 2018

v1.0.0-alpha.4

1.0.0.0-alpha4

An validation tool for arrays filled by foreign input

  Sources   Download

MIT

The Requires

  • php ^7.0
  • ext-json *

 

The Development Requires

26/11 2017

v1.0.0-alpha.3

1.0.0.0-alpha3

An validation tool for arrays filled by foreign input

  Sources   Download

MIT

The Requires

  • php ^7.0
  • ext-json *

 

The Development Requires

26/11 2017

dev-error-object

dev-error-object

An validation tool for arrays filled by foreign input

  Sources   Download

MIT

The Requires

  • php ^7.0
  • ext-json *

 

The Development Requires

12/09 2017

v1.0.0-alpha.2

1.0.0.0-alpha2

An validation tool for arrays filled by foreign input

  Sources   Download

MIT

The Requires

  • php ^7.0
  • ext-json *

 

The Development Requires

08/09 2017

v1.0.0-alpha.1

1.0.0.0-alpha1

An validation tool for arrays filled by foreign input

  Sources   Download

MIT

The Requires

  • php ^7.0
  • ext-json *

 

The Development Requires