Download the PHP package everest/validation without Composer

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

Everest - Validation Component

The Validation Component of Everest is ment to validate user input in a simple and intuitive way.

Installing

Simply go to your project directory where the composer.json file is located and type:

Usage

This package offers two methods of data validation. You can either validate a single value on a specific requirement (type) or you can validate one or more validation chains on each key of an array or array like object.

Validating single value

Validating an array of values using a validation chain

You can use additional validation chains by seperating them with ->or()

Strict and lazy validation

One can choose between Validate::strict() and Validate::lazy(). First will throw an InvalidValidationException on the first occuring error and the last will collect all occuring errors and will throw a InvalidLazyValidationException, which provices a ::getErrors() and ::getErrorsGroupedByKey() method to access all bundled InvalidValidationException exceptions.

Validating nested arrays

One can use dot-notation to validate nested values.

Optional parameters

Parameters can be marked as optional and as optional with default. If the validation ueses a default value as fallback this value is NOT validated by the validation chain anymore!

Types

Types are rules that a supplied value has to fulfill.

Array

Validation::array($value), validates that given value is an array.

Between

Validation::between($value, numeric $min, numeric $max), validates that given value holds $min <= $value <= $max.

Boolean

Validation::boolean($value), validates that given value is a boolean or booleanish value. The result will be casted to a boolean. This type inteprets $value as follows:

Value Result
true true
'true' true
1 true
'1' true
false false
'false' false
0 false
'0' false

Every other value will throw an InvalidValidationException.

DateTime

Validation::dateTime($value, string $pattern), validates that given value matches the supplied date pattern and returns a new DateTime instance.

DateTimeImmutable

Same as DateTime but returns a new DateTimeImmutable instance.

Enum

Validation::dateTime($value, array $enum), validates that given value matches one of the $enum values. If $enum is an assoc array it tryes to match $value against the keys and returns the associated value.

Float

Validation::float($value), validates that given value is numeric. The result will be casted to a float.

Integer

Validation::integer($value), validates that given value is an integer or integerish. The result will be casted to an integer.

KeyExists

Validation::keyExisits($value, $key), validates that given value is an array and that the supplied key exists in this array.

Length

Validation::length($value, int $length), validates that given value matches the supplied string length using strlen.

LengthBetween

Validation::lengthBetween($value, int $min, int $max), validates that given values string length is between supplied minimum and maximum.

LengthMax

Validation::lengthMax($value, int $max), validates that given values string length lower or equal supplied maximum.

LengthMin

Validation::lengthMin($value, int $min), validates that given values string length greater or equal supplied minimum.

Max

Validation::max($value, int $max), validates that the given numerical value is lower or equal supplied maximum.

Min

Validation::min($value, int $max), validates that the given numerical value is greater or equal supplied minimum.

NotEmpty

Validation::notEmpty($value), validates that the given value is not empty.

Null

Validation::null($value), validates that the given value is null.

String

Validation::string($value), validates that the given value is a string.

Filters

Filters can be used to transfrom the validated result.

LowerCase

Validation::lowerCase($value), executes strtolower on the supplied value.

StripTags

Validation::stripTags($value), executes strip_tags on the supplied value.

Trim

Validation::trim($value), executes trim on the supplied value.

UpperCase

Validation::upperCase($value), executes strtoupper on the supplied value.

Custom Types

One can add custom types by creating a new class that extends from Everest\Validation\Types\Type.

In the next step you need to connect your type with the Everest\Validation\Validation class.

If you want to overload an existing type you need to pass true as third argument to \Everest\Validation\Validation::addType.

Now you can use the custom type by Validation::custom_type($var) or in a validation chain with ->custom_type().

License

This project is licensed under the MIT License - see the LICENSE.md file for details


All versions of validation with dependencies

PHP Build Version
Package Version
Requires php Version >=8.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 everest/validation contains the following files

Loading the files please wait ....