Download the PHP package alleyinteractive/laminas-validator-extensions without Composer

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

Laminas Validator Extensions

This package provides additional validation classes for the Laminas Validator framework, plus a custom base validation class.

Installation

Install the latest version with:

Basic usage

For more information about what validators do, how to use them, and how to write your own, visit the Laminas documentation.

Base validators

ExtendedAbstractValidator

The abstract Alley\Validator\ExtendedAbstractValidator class standardizes the implementation of custom validators with \Laminas\Validator\AbstractValidator.

When extending ExtendedAbstractValidator, validation logic goes into a new testValue() method, which is responsible only for applying the logic and adding any validation errors. It's no longer necessary to call setValue() prior to evaluating the input, and isValid() will return true if there are no error messages after evaluating the input and false if there are any messages.

Before:

After:

FreeformValidator

The standalone, abstract Alley\Validator\FreeformValidator class leaves most of the implementation details to your discretion, but it's often easier to use for validators that are project-specific or not ready for wider distribution.

Like the ExtendedAbstractValidator class, the FreeformValidator expects that validation logic goes into a testValue() method, and isValid() will return true or false based on whether there are error messages.

Validation errors can be added using the error() method, which accepts the message key and text.

"Any Validator" chains

\Alley\Validator\AnyValidator is like a Laminas validator chain except that it connects the validators with "OR," marking input as valid as soon it passes one of the given validators.

Unlike a Laminas validator chain, validators can only be attached, not prepended, and there is no $priority argument.

Basic usage

"Fast fail" validator chains

\Alley\Validator\FastFailValidatorChain is like a Laminas validator chain except that if a validator fails, the chain will automatically be broken; there is no $breakChainOnFailure parameter.

Unlike a Laminas validator chain, validators can only be attached, not prepended, and there is no $priority argument.

Basic usage

Validators by operator name

\Alley\Validator\ValidatorByOperator allows you to access a validator using a readable operator name, such as REGEX or NOT IN.

Its primary use case is to allow you to write functions that accept the readable operator names as parameters while using validators internally. Here's a demonstrative function call from the wp-match-blocks library:

The supported operator names are:

Any operator name that isn't forwarded to a different validator must be a valid Comparison operator.

Basic usage

Validators

AlwaysValid

\Alley\Validator\AlwaysValid marks all input as valid. It can be used to satisfy type requirements when full validation needs to be disabled or is impractical.

Supported options

None.

Basic usage

Comparison

\Alley\Validator\Comparison compares input to another value using a PHP comparison operator. The input passes validation if the comparison is true. Input is placed on the left side of the operator.

Supported options

The following options are supported for \Alley\Validator\Comparison:

Basic usage

ContainsString

\Alley\Validator\ContainsString is a validator around the str_contains() function. Each instance of the validator represents the "needle" string and validates whether the string is found within the input "haystack." Inputs will automatically be cast to strings.

Supported options

The following options are supported for \Alley\Validator\ContainsString:

Basic usage

DivisibleBy

\Alley\Validator\DivisibleBy allows you to validate whether the input is evenly divisible by a given numeric value. Inputs will automatically be cast to integers.

Supported options

The following options are supported for \Alley\Validator\DivisibleBy:

Basic usage

Not

Alley\Validator\Not inverts the validity of a given validator. It allows for creating validators that test whether input is, for example, "not one of" in addition to "one of."

Supported options

None.

Basic usage

OneOf

Alley\Validator\OneOf validates whether an array of scalar values contains the input.

OneOf is a simpler version of \Laminas\Validator\InArray that accepts only scalar values in the haystack and does only strict comparisons. In return, it produces a friendlier error message that lists the allowed values.

Supported options

The following options are supported for \Alley\Validator\OneOf:

Basic Usage

Type

\Alley\Validator\Type allows you to validate whether the input is of the given PHP type. The input passes if it is the expected type.

This validator is inspired by PHPUnit's \PHPUnit\Framework\Constraint\IsType class.

Supported options

The following options are supported for \Alley\Validator\Type:

Basic usage

WithMessage

Alley\Validator\WithMessage allows you to decorate a validator with a custom failure code and message, replacing the validator's usual failure messages.

Supported options

None.

Basic usage

About

License

GPL-2.0-or-later

Maintainers

Alley Interactive


All versions of laminas-validator-extensions with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0
laminas/laminas-validator Version ^2.20
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 alleyinteractive/laminas-validator-extensions contains the following files

Loading the files please wait ....