Download the PHP package codezero/validator without Composer

On this page you can find all versions of the php package codezero/validator. 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 validator

Form Input Validator

Build Status Latest Stable Version Total Downloads License

This package provides an easy to use interface to handle server side form validation and lets you create your custom form validation classes without much effort.

Although the core of this package is not bound to any framework, I have included a ServiceProvider and ValidationService implementation specifically for Laravel.

I have also included a ValidationTrait and a facade (both for Laravel) so you can use this package in a way you like best (see below for more).

Installation

Install this package through Composer:

"require": {
    "codezero/validator": "1.*"
}

Laravel 4 Implementation

After installing, update your app/config/app.php file to include a reference to this package's service provider in the providers array:

'providers' => [
    'CodeZero\Validator\ValidatorServiceProvider'
]

This package will automatically register the Validate alias, if this is not already taken.

You can handle failed validations by catching the ValidationException. One automated way is to add the following handler to app/start/global.php. But you could as easily catch it in a try/catch block.

App::error(function(CodeZero\Validator\Exceptions\ValidationException $exception)
{
    return Redirect::back()->withInput()->withErrors($exception->getErrors());
});

Laravel Specific Usage

1. Create a FormValidator to validate your form

use CodeZero\Validator\FormValidator;

class UpdateUserForm extends FormValidator {

    /**
     * Validation rules
     *
     * @var array
     */ 
    protected $rules = [
        'name' => 'required',
        'email' => 'required|email|unique,email,{userId}'
    ];

}

Note the {userId} placeholder as an example.

2. Handle the input

Create your form and then handle the input in your controller in one of the following ways.

Validate with a facade:
$input = Input::all();
$vars = ['{userId}' => $someUser->id];

Validate::form('UpdateUserForm', $input, $vars);

You can pass the input and any placeholder key/value pairs as the second and third parameter, but if you leave both off, the package will automatically fetch Input::all() for you.

To have typesafety or autocomplete in IDE's, you might do this instead:

Validate::form(get_class(UpdateUserForm), $input, $vars);

Or if you use PHP 5.5 or above, this is even cleaner:

Validate::form(UpdateUserForm::class, $input, $vars);
Validate with a trait:
use CodeZero\Validator\Support\ValidatorTrait;

class HomeController extends BaseController {

    use ValidatorTrait;

    public function update()
    {
        $input = Input::all();
        $vars = ['{userId}' => $someUser->id];

        $this->validate(UpdateUserForm::class, $input, $vars);

        return Redirect::to('/');
    }

}

3. Show any validation errors

Showing the errors in your form is as easy as doing this for each field:

{{ $errors->first('name', '<p>:message</p>'); }}

That's it!


All versions of validator with dependencies

PHP Build Version
Package Version
Requires php Version >=5.4.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 codezero/validator contains the following files

Loading the files please wait ....