Download the PHP package frangeris/simple-validation without Composer

On this page you can find all versions of the php package frangeris/simple-validation. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package simple-validation

Simple validation for PHP 5.5+

There are so many differents ways to make a validation for forms on php, each framework(Laravel 4+, Symfony 2+, CodeIgniter , FuelPHP, CakePHP, bla bla bla) has their own implementation on validations, ok, that's ok, it is expected that they supply us that funcionality, but, sometimes all those validations are complicated, sometimes we dont want to insert the rules inside a model when we just wanna validate a simple html form and get the possible failures, just simple like that, it ok that you insert your rules inside your model, this is another way just with super powers...

Installation

Easiest way would be using Composer and adding this to the composer.json requirement section.

It's PSR-0 compliant, so you can also use your own custom autoloader.

Usage

In general, every form could have rules, what is a rule?, rule is just what you want to validate, just like that, here is the list of rules we support:

So let's rock and roll:

Here is an example of the structure for write your own validations, in this case I wanna validate a form for just save users over 18 years old, and of course a valid first name, last name and email.

file with rules:

As you can see frm_user_add is the name of a form, followed by an associative array for the fields requirements and messages.

email is a field inside the form frm_build_add, we wanna that this field exist and must to be valid using the filters inside PHP, depending of each error, the string inside message is gonna be returned... Awesome right? :D

f_name is a little complicated, is this case we want that the field be required, > 3 and < 30, and needs to match with the regular expression /^[a-z ]+$/i...

For l_name acts the same rule that f_name...

And the last one age, I just wanna that exist, and the minimun value must to be 18, and that's it... :)

In the PHP side just call the validator class and pass the fields on request and the name of the form:

This example is using phalcon framework making a POST request

The required function can be placed in another place, just remember that the isValid method needs this array for validate...

PS: If you are using phalcon, dont do this in this way, create a DI inside your services and use it as di, someting like:



// Set up the validator service
$di->set('validator', function() use ($config)
{
    $validations = require_once($config->security->validations);
    return Simple\Validation\Validator::getInstance($validations);
});

All versions of simple-validation with dependencies

PHP Build Version
Package Version
Requires php Version >=5.5.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package frangeris/simple-validation contains the following files

Loading the files please wait ....