Download the PHP package popphp/pop-validator without Composer

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

pop-validator

Build Status Coverage Status

Join the chat at https://discord.gg/TZjgT74U7E

Overview

pop-validator is a component for validating values and returning the appropriate result messaging. The component comes with a set of built-in evaluation objects and also the ability to extend the component and build your own.

pop-validator is a component of the Pop PHP Framework.

Top

Install

Install pop-validator using Composer.

composer require popphp/pop-validator

Or, require it in your composer.json file

"require": {
    "popphp/pop-validator" : "^4.5.0"
}

Top

Quickstart

Here's a list of the available built-in validators, all under the namespace Pop\Validator\:

Built-in Validators
Accepted Email IsSubnetOf
AlphaNumeric EndsWith LengthBetweenInclude
Alpha Equal LengthBetween
BetweenInclude GreaterThanEqual LengthGreaterThanEqual
Between GreaterThan LengthGreaterThan
Boolean HasCountEqual LengthLessThanEqual
Contains HasCountGreaterThanEqual LengthLessThan
CountEqual HasCountGreaterThan Length
CountGreaterThanEqual HasCountLessThanEqual LessThanEqual
CountGreaterThan HasCountLessThan LessThan
CountLessThanEqual HasCountNotEqual NotContains
CountLessThan HasOne NotEmpty
CountNotEqual HasOneThatEquals NotEndsWith
CreditCard HasOnlyOne NotEqual
DateTimeBetweenInclude HasOnlyOneThatEquals NotInArray
DateTimeBetween InArray NotIn
DateTimeEqual In NotStartsWith
DateTimeGreaterThanEqual Ipv4 Numeric
DateTimeGreaterThan Ipv6 RegEx
DateTimeLessThanEqual IsArray Required
DateTimeLessThan IsEmpty StartsWith
DateTimeNotEqual IsJson Subnet
Declined IsNotEmpty Url

Check an email value

Validate against a specific value

Set a custom message

Alternatively:

Top

Validation Sets

Validation sets are a way to group validators together to evaluate all of them at one time. With that, a level of strictness can be set to enforce whether or not all the validations have to pass or just some of them.

Multiple Validators

Custom Messaging

Lazy-Loading vs Eager-Loading

If the validators are added to the set validator using the add* methods will store the validator configuration and not create the validator objects until the validator set is evaluated (lazy-loading.) Using the load* methods, actual validator objects will be stored in the instance of the validator set object (eager-loading.)

Strictness

The strictness of the validator set can be set as needed. If set to STRICT_NONE then only one validator in the set would have to pass in order for the whole set to pass. The same applies for conditions as well:

Available strict constants are:

Top

Conditions

Conditions can be added to a validation set that would need to pass in order for the validations to evaluate. Conditions are validators themselves. And the strictness level can be utilized as well to enforce whether or not all the conditions pass or just some of them.

Note: By default, conditions store their validation configuration via lazy-loading and do not create the validator object until the condition is evaluated.

In the above example, if the value of client_id is changed to 2, the validators will not be evaluated, as the required conditions would not be satisfied.

Top

Rules

Rules provide a shorthand way to wire up validations and conditions within the validation set. Rules are colon-separated strings compromised of a field, a validator and optional value and message values. The validator should be a snake_case format of the class string, e.g. HasOne class should be written as has_one.

Below is the same example from above, but using rules instead:

Conditions can be added using rules as well. Here is the example from above using rules instead:

Rule Messages

Custom messaging can be passed via the rule format as well, in the 4th position:

Referencing Fields

When writing rules, fields passed into the input data at the time of evaluating the data can be accessed by using brackets:

Top


All versions of pop-validator with dependencies

PHP Build Version
Package Version
Requires php Version >=8.2.0
popphp/pop-utils Version ^2.2.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 popphp/pop-validator contains the following files

Loading the files please wait ....