2017 © Pedro Peláez
 

library ebt-validator

A simple service that provides common PHP validations

image

ebidtech/ebt-validator

A simple service that provides common PHP validations

  • Monday, January 30, 2017
  • by ebidtech
  • Repository
  • 14 Watchers
  • 0 Stars
  • 1,153 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 15 Versions
  • 1 % Grown

The README.md

EBT Validator

This project provides the ValidatorService class. This class encapsulates a few common validations, allowing both required and optional validations., (*1)

Installation

The recommended way to install is through composer., (*2)

Just create a composer.json file for your project:, (*3)

``` json { "require": { "ebidtech/ebt-validator": "2.*" } }, (*4)


And run these two commands to install it: ```bash $ curl -sS https://getcomposer.org/installer | php $ composer install

Now you can add the autoloader, and you will have access to the library:, (*5)

<?php

require 'vendor/autoload.php';

Example

// Instantiate the validator.
$validator = new EBT\Validator\Service\Validator\ValidatorService();

// Validations return TRUE when they succeed, FALSE when they fail.
$validator->requireString('a string');         // true
$validator->requiredInteger('not an integer'); // false

// It is possible to retrieve the message for the last
// failed validation.
$validator->requireString(5);                  // false
$validator->getLastError();                    // 'Expected string, "integer" given.'

// It is also possible to pass an additional parameter to any validation method
// to control whether or not exceptions are suppressed when a validation fails.
// By default, exceptions suppressed.
$validator->requirePositiveInteger(-1);        // false
$validator->requirePositiveInteger(-1, true);  // false
$validator->requirePositiveInteger(-1, false); // throws ValidationException

// Required validations will fail if the value is not defined, 
// optional validations will not.
$validator->requiredPositiveInteger(null);     // false
$validator->optionalPositiveInteger(null);     // true

// The validator can also be used statically, keeping the same
// behavior. Note that the static validator sacrifices advanced
// features (for example, error messages) to improve performance
// and avoid validator instantiation.
use EBT\Validator\Model\Validator\Validator;

Validator::requireString('a string');          // true
Validator::requiredInteger('not an integer');  // false

The Versions

30/01 2017

dev-master

9999999-dev https://github.com/ebidtech/ebt-validator

A simple service that provides common PHP validations

  Sources   Download

MIT

The Requires

 

The Development Requires

30/01 2017

v2.0.4

2.0.4.0 https://github.com/ebidtech/ebt-validator

A simple service that provides common PHP validations

  Sources   Download

MIT

The Requires

 

The Development Requires

18/08 2016

v2.0.3

2.0.3.0 https://github.com/ebidtech/ebt-validator

A simple service that provides common PHP validations

  Sources   Download

MIT

The Requires

 

The Development Requires

06/01 2016

v2.0.2

2.0.2.0 https://github.com/ebidtech/ebt-validator

A simple service that provides common PHP validations

  Sources   Download

MIT

The Requires

 

The Development Requires

06/01 2016

v2.0.1

2.0.1.0 https://github.com/ebidtech/ebt-validator

A simple service that provides common PHP validations

  Sources   Download

MIT

The Requires

 

The Development Requires

06/01 2016

v2.0.0

2.0.0.0 https://github.com/ebidtech/ebt-validator

A simple service that provides common PHP validations

  Sources   Download

MIT

The Requires

 

The Development Requires

21/07 2015

v1.2.1

1.2.1.0 https://github.com/ebidtech/ebt-validator

A simple service that provides common PHP validations

  Sources   Download

MIT

The Requires

 

The Development Requires

21/07 2015

v1.2.0

1.2.0.0 https://github.com/ebidtech/ebt-validator

A simple service that provides common PHP validations

  Sources   Download

MIT

The Requires

 

The Development Requires

16/07 2015

v1.1.3

1.1.3.0 https://github.com/ebidtech/ebt-validator

A simple service that provides common PHP validations

  Sources   Download

MIT

The Requires

 

The Development Requires

16/07 2015

v1.1.2

1.1.2.0 https://github.com/ebidtech/ebt-validator

A simple service that provides common PHP validations

  Sources   Download

MIT

The Requires

 

The Development Requires

16/07 2015

v1.1.1

1.1.1.0 https://github.com/ebidtech/ebt-validator

A simple service that provides common PHP validations

  Sources   Download

MIT

The Requires

 

The Development Requires

16/07 2015

v1.1.0

1.1.0.0 https://github.com/ebidtech/ebt-validator

A simple service that provides common PHP validations

  Sources   Download

MIT

The Requires

 

The Development Requires

15/07 2015

v1.0.2

1.0.2.0 https://github.com/ebidtech/ebt-validator

A simple service that provides common PHP validations

  Sources   Download

MIT

The Requires

 

The Development Requires

14/07 2015

v1.0.1

1.0.1.0 https://github.com/ebidtech/ebt-validator

A simple service that provides common PHP validations

  Sources   Download

MIT

The Requires

 

The Development Requires

13/07 2015

v1.0.0

1.0.0.0 https://github.com/ebidtech/ebt-validator

A simple service that provides common PHP validations

  Sources   Download

MIT

The Requires

 

The Development Requires