Download the PHP package hylianshield/validator without Composer

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

HylianShield Validator

The HylianShield validator is a validation package, built to create a common validator interface.

Its current release is explicitly built with PHP7 in mind. When compared to its predecessor, the current version of the HylianShield validator package is stripped down to the bare essential needs for validation.

Installation

composer require hylianshield/validator:^2.1.0

Configuration

For this package, there is no configuration to consider.

Validator

A validator consists of at least the following two methods:

getIdentifier

This method is used to create a unique identifier for the validator. It is of use when debugging behavior of validators or identifying validators that have blocked out certain validation subjects.

validate

The validate method accepts a validation subject and returns whether the subject is or is not valid.

Validator Collection

Besides an interface for validators to implement, a validator collection interface is exposed.

This collection itself implements an interface that extends the validator interface. Therefore, a validator collection itself is a validator.

Besides the shared functionality of a validator, it has a method to add a validator, as well as a method to remove a validator.

If the validate method is called on a collection, it will validate against the validators inside the collection.

Depending on which of the following collections is used, the validation result will differ:

Collection Result
MatchAllCollection Returns true when all internal validators return true.
MatchNoneCollection Returns true when all internal validators return false.
MatchAnyCollection Returns true when any internal validator returns true.

Because a collection is a validator itself, it can accept another collection as a registered validator.

Note: To not negatively impact performance, there is no test against registering collections recursively. Because of this, when a collection is poorly built, it may render function nesting overflows.

Additionally, the collections keep nesting the formatting of identifiers. Given that a MatchAnyCollection holds validators with identifiers Foo and Bar, respectively, the identifier of the collection will be:

If one would nest a level deeper, combined with MatchAllCollection, one can get the following:

This particular validator will pass if the Foo validator passes, if both the Bar and Baz validators pass or if all three validators pass.

NotValidator

When one wants to invert the validation of any given validator or collection, one can wrap it around a NotValidator.

Anonymous validator

As of PHP 7, PHP supports anonymous classes. One can easily create a custom validator without having to introduce a fully qualified class name for its validator.

And with this you have created a validator that can assert if a given user exists.

You could even combine it with existing validators.

Invoker

In previous versions of this package, one could pass a validator on to functions like array_filter and array_map.

To properly separate concerns in code and to keep the validator interface clean for implementations, this is now solved by a separate Invoker object.

One simply wraps the validator like so:

This also works for validator collections.

See invoker code example under examples/ for an implementation of the invoker.


All versions of validator with dependencies

PHP Build Version
Package Version
Requires php Version ^7.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 hylianshield/validator contains the following files

Loading the files please wait ....