Download the PHP package programmatordev/fluent-validator without Composer

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

Fluent Validator

Latest Version Tests

A Symfony Validator wrapper that enables fluent-style validation for raw values, offering an easy-to-use and intuitive API to validate user input or other data in a concise and readable manner.

Features

Table of Contents

Requirements

Installation

Install via Composer:

Usage

Simple usage example:

Constraints autocompletion is available in IDEs like PhpStorm. The method names match Symfony constraints but with a lowercase first letter:

For all available constraints, check the Constraints section.

For all available methods, check the Methods section.

There is also a section for Translations.

Constraints

All available constraints can be found on the Symfony Validator documentation.

For custom constraints, check the Custom Constraints section.

Methods

validate

Returns a ConstraintViolationList object, acting as an array of errors.

assert

Throws a ValidationFailedException when validation fails.

isValid

Returns a bool indicating if the value is valid.

getConstraints

Returns an array with all added constraints.

It is useful for Composite constraints (i.e., a constraint that is composed of other constraints) and keeps the fluent-style validation:

addNamespace

Used to add namespaces for custom constraints.

Check the Custom Constraints section.

setTranslator

Used to add a translator for validation error message translations.

Check the Translations section.

Custom Constraints

If you need a custom constraint, follow the Symfony Validator documentation: Creating Custom Constraints.

Example: Creating a ContainsAlphanumeric Constraint

1. Create a Constraint Class

This class defines the error message and configurable options.

2. Create the Validator Class

The validator checks if the value complies with the constraint rules.

3. Register the Constraint Namespace

Register the namespace where the custom constraints will be located in your project.

You can have multiple constraints in the same namespace or have multiple namespaces.

[!NOTE] Custom constraints will not be suggested in IDE autocompletion.

Translations

Set a global translator to handle error message translations.

To add your own translations, you can integrate a custom translator.

Contributing

Any form of contribution to improve this library (including requests) will be welcome and appreciated. Make sure to open a pull request or issue.

License

This project is licensed under the MIT license. Please see the LICENSE file distributed with this source code for further information regarding copyright and licensing.


All versions of fluent-validator with dependencies

PHP Build Version
Package Version
Requires php Version >=8.2
symfony/config Version ^7.2
symfony/translation Version ^7.2
symfony/validator Version ^7.2
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 programmatordev/fluent-validator contains the following files

Loading the files please wait ....