Download the PHP package valid8r/valid8r_php without Composer

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

REPO ARCHIVED

This is quite old, no one should be using it.

Valid8r - Validation for multiple programming languages.

Valid8r for PHP

Valid8r is a validation library for multiple programming languages using a common JSON configuration file. Learn more about Valid8r and the configuration file at:

https://github.com/thomporter/valid8r

Installation

Valid8r for PHP really only has one file you need. If you don't care about testing, examples, etc, you can simply grab the Valid8r.php file from the lib/Valid8r folder:

https://raw.github.com/thomporter/valid8r_php/master/lib/Valid8r/Valid8r.php

Alternatively, you can clone this rep and get examples & tests.

You can also install via Composer:

{
  "require": {
    "valid8r/valid8r_php": ">=v0.0.3"
  }
}

Examples

Get the Examples folder running on an PHP enabled web server and you can check out the Kitchen Sink examples.

Here's a quick idea of how it works in PHP:

<?php
$validator = new Valid8r(Array(
    'rules_file' => '/path/to/your/rules.json',
    'data' => $_POST // assumed to be slash-free
));
$errors = $validator->validateAll();
// errors is now an associative array, where the keys are fields with 
// errors, and values are the errors themselves.  
// Fields with no errors are not in the array.

if (!empty($errors)) {
    // there was at least one error in the form...
}

if (@$errors['field_name']) {
    // field_name has an error, the error string is in $errors['field_name']
}

Custom Validators

For general information about Custom Validators, see the main Valid8r docs

Valid8r for PHP supports custom validators via any of the following:

No matter which you use, your function must accept 2 arguments ($field & $value) and must either return a string to use as the error, or a blank string if no error.

Custom Validators using Standard Functions

Just use the function name as the value for the func property of your custom rule and Valid8r will access it directly.

Custom Validators using Static Methods

You can add a php_static_class to your custom rule and Valid8r will combine that with the func property to build the call:

$php_static_class::$func($field, $value)

You can also add a php_namespace which will cause Valid8r to make the call like so:

$php_namespace\$php_static_class::$func($field, $value)

Custom Validators using Instance Methods

If you need Valid8r to initialize a class, and then call a method on it, this is the options for you. Add a php_class property, and Valid8r will make the call like so:

$validator = new $php_class
$validator->$func($field, $value)

Tests

PHPUnit tests are available if you clone/download the repo. Once you have PHPUnit installed, you can run the tests with:

`run-tests`

All versions of valid8r_php with dependencies

PHP Build Version
Package Version
Requires php Version >=5.3.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 valid8r/valid8r_php contains the following files

Loading the files please wait ....