PHPackages                             icanboogie/validate - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Validation &amp; Sanitization](/categories/validation)
4. /
5. icanboogie/validate

ActiveLibrary[Validation &amp; Sanitization](/categories/validation)

icanboogie/validate
===================

Validate data against a set of rules

v0.2.1(5y ago)11.7k↓77.8%1BSD-3-ClausePHPPHP &gt;=5.5

Since Jan 24Pushed 1y agoCompare

[ Source](https://github.com/ICanBoogie/Validate)[ Packagist](https://packagist.org/packages/icanboogie/validate)[ Docs](https://icanboogie.org/)[ RSS](/packages/icanboogie-validate/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependencies (2)Versions (8)Used By (1)

Validate
========

[](#validate)

[![Release](https://camo.githubusercontent.com/2e0947fc9168313852b70bd1656b781e72a70e798d4672a3261fe77928c4fc0b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6963616e626f6f6769652f76616c69646174652e737667)](https://packagist.org/packages/icanboogie/validate)[![Build Status](https://camo.githubusercontent.com/eaf9df0c6404af9a4c02e7e7f794a50fdc2f5a0e24b8205132874cd56768f3f2/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f4943616e426f6f6769652f56616c69646174652e737667)](http://travis-ci.org/ICanBoogie/Validate)[![Code Quality](https://camo.githubusercontent.com/ba0e0b4714a6cf18a1967b63068c50c2e057cb0eedee35efa0b953496634fcee/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f6963616e626f6f6769652f76616c69646174652e737667)](https://scrutinizer-ci.com/g/ICanBoogie/Validate)[![Code Coverage](https://camo.githubusercontent.com/79c41922ed59d4f3c4f0ebbe1c6effd6888a407c6b2e15a22e068308df589b11/68747470733a2f2f696d672e736869656c64732e696f2f636f766572616c6c732f4943616e426f6f6769652f56616c69646174652e737667)](https://coveralls.io/r/ICanBoogie/Validate)[![Packagist](https://camo.githubusercontent.com/db72a2c074ae1288ac5f3883fa686524a9f8d427cd744262f652efc88272626f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6963616e626f6f6769652f76616c69646174652e737667)](https://packagist.org/packages/icanboogie/validate)

The **icanboogie/validate** package offers a simple API to validate data.

The following validators are available:

- Flags

    - [Required](https://icanboogie.org/api/validate/master/class-ICanBoogie.Validate.Validator.Required.html), `required`: States that a value is required. Should be specified first.
- Generic

    - [Blank](https://icanboogie.org/api/validate/master/class-ICanBoogie.Validate.Validator.Blank.html), `blank`: Validates that a value is blank.
    - [NotBlank](https://icanboogie.org/api/validate/master/class-ICanBoogie.Validate.Validator.NotBlank.html), `not-blank`: Validates that a value is blank.
- Type comparison

    - [Boolean](https://icanboogie.org/api/validate/master/class-ICanBoogie.Validate.Validator.Boolean.html), `boolean`: Validates that a value is a boolean.
    - [IsFalse](https://icanboogie.org/api/validate/master/class-ICanBoogie.Validate.Validator.IsFalse.html), `is-false`: Validates that a value is false.
    - [IsNull](https://icanboogie.org/api/validate/master/class-ICanBoogie.Validate.Validator.IsNull.html), `is-null`: Validates that a value is `null`.
    - [NotNull](https://icanboogie.org/api/validate/master/class-ICanBoogie.Validate.Validator.NotNull.html), `not-null`: Validates that a value is not `null`.
    - [IsTrue](https://icanboogie.org/api/validate/master/class-ICanBoogie.Validate.Validator.IsTrue.html), `is-true`: Validates that a value is true.
    - [Type](https://icanboogie.org/api/validate/master/class-ICanBoogie.Validate.Validator.Type.html), `type`: Validates that a value is of a specified type.
- Reference comparison

    - [Equal](https://icanboogie.org/api/validate/master/class-ICanBoogie.Validate.Validator.Equal.html), `equal`: Validates that two values are equal.
    - [NotEqual](https://icanboogie.org/api/validate/master/class-ICanBoogie.Validate.Validator.NotEqual.html), `not-equal`: Validates that two values are not equal.
    - [Identical](https://icanboogie.org/api/validate/master/class-ICanBoogie.Validate.Validator.Identical.html), `identical`: Validates that two values are identical.
    - [NotIdentical](https://icanboogie.org/api/validate/master/class-ICanBoogie.Validate.Validator.NotIdentical.html), `not-identical`: Validates that two values are not identical.
    - [Max](https://icanboogie.org/api/validate/master/class-ICanBoogie.Validate.Validator.Max.html), `max`: Validates that a value has a maximum value.
    - [MaxLength](https://icanboogie.org/api/validate/master/class-ICanBoogie.Validate.Validator.MaxLength.html), `max-length`: Validates that a value has a maximum length.
    - [Min](https://icanboogie.org/api/validate/master/class-ICanBoogie.Validate.Validator.Min.html), `min`: Validates that a value has a minimum value.
    - [MinLength](https://icanboogie.org/api/validate/master/class-ICanBoogie.Validate.Validator.MinLength.html), `min-length`: Validates that a value has a minimum length.
- Range comparison

    - [Between](https://icanboogie.org/api/validate/master/class-ICanBoogie.Validate.Validator.Between.html), `between`: Validates that a value is between two references.
    - [NotBetween](https://icanboogie.org/api/validate/master/class-ICanBoogie.Validate.Validator.NotBetween.html), `not-between`: Validates that a value is not between two references.
    - [BetweenLength](https://icanboogie.org/api/validate/master/class-ICanBoogie.Validate.Validator.BetweenLength.html), `between-length`: Validates that a string length is between two references.
    - [NotBetweenLength](https://icanboogie.org/api/validate/master/class-ICanBoogie.Validate.Validator.NotBetweenLength.html), `not-between-length`: Validates that a string length is not between two references.
- String comparison

    - [Email](https://icanboogie.org/api/validate/master/class-ICanBoogie.Validate.Validator.Email.html), `email`: Validates that a value is a valid email.
    - [JSON](https://icanboogie.org/api/validate/master/class-ICanBoogie.Validate.Validator.JSON.html), `json`: Validates that a value is a valid JSON.
    - [Regex](https://icanboogie.org/api/validate/master/class-ICanBoogie.Validate.Validator.Regex.html), `regex`: Validates that a value matches or not a pattern.
    - [TimeZone](https://icanboogie.org/api/validate/master/class-ICanBoogie.Validate.Validator.TimeZone.html), `timezone`: Validates that a value is a valid time zone.
    - [URL](https://icanboogie.org/api/validate/master/class-ICanBoogie.Validate.Validator.URL.html), `url`: Validates that a value is a valid URL.

The following example demonstrates how data may be validated:

```
