Download the PHP package memio/validator without Composer
On this page you can find all versions of the php package memio/validator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download memio/validator
More information about memio/validator
Files in memio/validator
Package validator
Short Description Memio's validator, used to check built models again a pre-defined set of rules
License MIT
Homepage http://memio.github.io/memio
Informations about the package validator
Memio's Validator
A validator library for Memio: allows to define Constraints
to check if the built
Memio models are valid
(e.g. Method
cannot be both abstract and final).
Note: This package is part of Memio, a highly opinionated PHP code generator. Have a look at the main repository.
Installation
Install it using Composer:
Example
Let's say we want to check that Arguments
aren't scalar. In order to do so,
the first thing we'll need to do is to write a Constraint
:
Note: In Memio, all
Constraints
are named after their error message. This isn't a hard coded rule, they can have any name.
We then need to register our rule in an ArgumentValidator
:
ArgumentValidator
is a ModelValidator
called by Validator
if the given model
is an Argument
. However, if the given model is a Method
we'd like Validator
to check our Constraint
against its Arguments
. To do so, we need to assemble
ModelValidators
as follow:
Finally, we need to create a validator and register our ModelValidators
in it:
This way we can build specialized validators: one that'd check syntax errors, one that'd check business rules, etc... Possibilities are endless!
Have a look at the main respository to discover the full power of Medio.
Want to know more?
Memio uses phpspec, which means the tests also provide the documentation. Not convinced? Then clone this repository and run the following commands:
You can see the current and past versions using one of the following:
- the
git tag
command - the releases page on Github
- the file listing the changes between versions
And finally some meta documentation:
- copyright and MIT license
- versioning and branching models
- contribution instructions