Download the PHP package ej3dev/veritas without Composer
On this page you can find all versions of the php package ej3dev/veritas. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download ej3dev/veritas
More information about ej3dev/veritas
Files in ej3dev/veritas
Package veritas
Short Description A pragmatic and concise validation library written in PHP
License MIT
Homepage https://github.com/ej3dev/Veritas
Informations about the package veritas
ej3dev\Veritas
A pragmatic and concise validation library written in PHP.
The idea behind Veritas is implement a flexible easy to use validation engine so you can write validation code as easy as you can build questions in everyday language.
Requirements
Veritas requires PHP 5.3 or later.
Installation
Veritas is a one-file-project with zero dependencies available on GitHub and Packagist. You have two options to install it:
Composer
Use Composer dependency Manager for PHP. Add the following to your composer.json
and run composer update
.
Single file require
Download the project package, find the file Verifier.php
and copy it wherever you want in your project working directory. Then use require_one
to include the file in your code:
Use
Composer autoload or single file require
Veritas support PSR-4 autoloading via Composer. Import third party code to your context with Composer autoloader:
or use classic file require:
Namespace import
Veritas is namespaced, but you can write less code using a single class into your context:
How validate a variable
You can validate any $var
in three simple steps:
-
1. Create new
Verifier
instance -
2. Add rules
- 3. Verify and get the result
Simple example
The Hello World example is something like this:
Chained validation
The available validators can be chained to build complex rules:
Output
All validators and rules returns the Verifier
instance to support fluent interface via method chaining. verify()
method is used to get the validation final result after apply all chained rules and validators. By default, verify()
return true
or false
but you can change this behavior calling the method with one or two parameters. For example:
Parameters of verify()
can be anonymous functions:
Build-in validators
Documentation is work-in-progress. Meanwhile you can take a look to the examples in the file tests/VerifierTest.php
is()
isEmail()
isUrl()
isIp()
isNull()
isNotNull()
isEmpty()
isNotEmpty()
Type validators
Documentation is work-in-progress. Meanwhile you can take a look to the examples in the file tests/VerifierTest.php
boo()
int()
dec()
num()
str()
arr()
obj()
res()
Rules
Documentation is work-in-progress. Meanwhile you can take a look to the examples in the file tests/VerifierTest.php
attr()
contain()
containAny()
date()
eq()
filter()
in()
ineq()
key()
len()
out()
regex()
value()
without()
Prefix not
for validators and rules
You can prepend any rule or type validator with prefix "not" to get the logical negation of that rule or type validator:
Changelog
v0.6.0 [master][Fr.23-May-2014]
- New validator type:
dec()
- Added support for prefix
not
in all rules and type validators - Added support for Badge Poser tags in README.md
- Verifier class tested against 484 unitary tests
- Small code fixed
v0.5.1 [master][Tu.20-May-2014]
- Verifier.php code fully documented
Verifier
constructor now support a optional parameter to configure init value for$test
variable- New built-in validators:
isEmpty()
,isNotEmpty()
- New rule:
containAny()
- Small code optimizations
v0.5.0 [master][Th.8-May-2014]
License
The MIT License (MIT)
Copyright (c) 2014 Emilio José Jiménez [email protected]
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.