Download the PHP package fishfin/php-valigator without Composer

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

Valigator: Stand-alone PHP Class for Data Sanitization and Validation

Lovers of minimalism, rejoice! Valigator is a stand-alone PHP class for data sanitization and validation. It has no library dependencies, implements programmer-friendly filter syntax, and is highly flexible. Its just one single class file, include it and you are already on the move!

Valigator, huh?

PHP API frameworks are picking up, fast. They are wonderfully minimalist, speedy, and vastly preferred over powerful yet sometimes clunky larger frameworks. To implement validations in API frameworks and projects, large vendor sources have to be installed, adding unnecessary additions to code-base and complexity. Valigator was created to address specifically that. And there's nothing that stops you from using Valigator in non-API projects. Go ahead, you'll love it!

Valigator Checklist:
  ✓ PHP (5.5.*, 5.6.*, 7.*)
  ✓ Stand-alone
  ✓ Data Sanitization
  ✓ Data Validation
  ✓ Simple
  ✓ Flexible
  ✓ Programmer-friendly

PS: Slim Framework 3 is awesome!

Yet Another Vali[dg]ator

Maybe. Maybe not. Yeah, Valigator draws inspiration from some of the good, nay, great ones. And adds its own good bits too. Just to get you interested: Filter Aliasing, Multiple Arguments, custom Labels, custom Validation Error Messages and more.

Anatomy of Valigator

Terminology

The Gears and Wheels

Its easier to proceed from here with an example. Lets say we want to validate the following fields:

Yes, you noticed it, camelCase is just my preference.

Now lets say we are receiving the following data in an array (if you are not receiving the data in an array, you will need to create an array):

Lets now create filters based on the data validation requirements we have, and add a few other useful things. Please read Important Notes in the code comments.

Now lets run the validator:

Lets try next iteration with slightly modified input.

Time for iteration 3:

And finally...

The Bells and Whistles

Now that you are comfortable with the basics, lets move on to some advanced stuff. Its advanced, but fret not, semantics are crazy easy!

Multiple Filters

You already know how to run multiple filters: the pipe '|'

Arguments to Filters

All positional arguments after ':', delimited by ',', can it get simpler than this?

If you are a programmer, you will know what to expect in positional arguments. That's your clue.

Custom Error Messages for Validation Filters

Validation filters emit default error messages if data does not match the filter. If you don't like the default messages, make your own! After arguments, put a ';' and start your custom error message, with single or double quotes.

Notice how filter2 had no arguments, so ':' was not required. If the error message itself doesn't contain any special characters, like the single or double quotes, ':' or ';', why, you may not even put the wrapping quotes!

Custom Error Messages with Special Tags

If you liked the custom error message, you will like this even better. {field}, {value}, {filter}, {args}, {arg1} ... {argn} are all special tags in validation error messages.

Just for fun, let's say the validation filter was called 'wildfur', with args 'yellow,striped'. Let's say the field for which it was run was 'animal' whose label was 'Animal' (either set automatically or explicity with 'label' key) and value of the field was 'cheetah'.

would emit error message:

Commenting out Individual Filters

Just put a '/' to comment out a filter from running. It will be very useful in debugging, I assure you.

Skipping Filter Blocks

Use special keyword 'skip' in filter list.

skip and skip:all means the same thing, whatever suits you.

Aliases of Popular Filters

Some popular filters and some arguments have aliases, because different programmers remember them as different names, programming quirks you see.

The Big List of Filters

Sanitization Filters

In-depth documentation is in progress, but so much so far should get you started easily! The PHP class is Production-ready.


All versions of php-valigator with dependencies

PHP Build Version
Package Version
Requires php Version 5.5.* || 5.6.* || 7.*
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 fishfin/php-valigator contains the following files

Loading the files please wait ....