Download the PHP package blakvghost/php-validator without Composer

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



![Packagist Version (custom server)](https://img.shields.io/packagist/v/BlakvGhost/php-validator?label=stable) ![Packagist Version (custom server)](https://img.shields.io/packagist/l/BlakvGhost/php-validator?label=Licence) ![Packagist Version (custom server)](https://img.shields.io/packagist/dt/BlakvGhost/php-validator?label=download)

About PHPValidator

A modern PHP library for data validation in your applications. PHPValidator provides a flexible and extensible approach to validating data using predefined rules or by creating custom validation rules.


Installation

Install PHPValidator via Composer:


Quick Start


Customize Messages

You can customize error messages or specify the default language:


Nested and Wildcard Notation

PHPValidator supports dot notation for validating deeply nested fields, as well as wildcard notation (*) to apply rules across arrays of data.

Nested Keys

Validate nested fields using dot notation:

Wildcard Notation

Use * as a wildcard to apply the same rule to all elements of an array:


Key Features


Predefined Rules

Basic Validation

Rule Example Description
required 'username' => 'required' Ensures the field is present in the data
string 'username' => 'string' Checks if the field is of string type
nullable 'optional_field' => 'nullable' Allows the field to be null or empty
not_nullable 'optional_field' => 'not_nullable' The field must not be null or empty

Text Validation

Rule Example Description
email 'email' => 'email' Validates a well-formed email address
alpha 'name' => 'alpha' Contains only alphabetic characters
numeric 'age' => 'numeric' Contains only numeric characters
alpha_num 'pseudo' => 'alpha_num' Contains only alphanumeric characters
lowercase 'username' => 'lowercase' Contains only lowercase alphabetic characters
uppercase 'username' => 'uppercase' Contains only uppercase alphabetic characters

Length Validation

Rule Example Description
min 'username' => 'min:8' Minimum length of a string
max 'username' => 'max:25' Maximum length of a string
size 'string' => 'size:7' Exact size of a string, integer, array, or file

Size Rule Examples:

Comparison Validation

Rule Example Description
in 'role' => 'in:admin,editor,viewer' Value must be in a predefined list
not_in 'value' => 'not_in:foo,bar' Value must not be in the specified list
same 'password_confirmation' => 'same:password' Field value equals another field's value
confirmed 'password_confirmation' => 'confirmed:password' Field matches another field (for confirmation)

Security Validation

Rule Example Description
password 'password' => 'password' Validates a secure password

File and URL Validation

Rule Example Description
file 'file' => 'file' Validates that a field is a file upload
url 'website' => 'url' Validates that a field is a valid URL
active_url 'website' => 'active_url' Validates that a field is a valid, active URL

Format Validation

Rule Example Description
bool 'is_admin' => 'bool' Validates that a field is a boolean
ip 'client_ip' => 'ip' Validates that a field is a valid IP address
json 'config' => 'json' Validates that a field is a valid JSON string

Conditional Validation

Rule Example Description
accepted 'terms_and_conditions' => 'accepted' Field is "yes", "on", "1", or true (useful for checkboxes)
accepted_if 'terms_and_conditions' => 'accepted_if:is_adult,true' Field is accepted if another field equals a value
required_with 'firstname' => 'required_with:lastname' Field is required if another field is present
not_required_with 'email' => 'not_required_with:phone_number' Field must not be present if another field is present

Extract Validated Data

The validated() method returns only fields that:


Create Custom Rules

Beyond predefined rules, you can create your own validation rules by implementing the Rule interface.

Example: CustomPasswordRule.php

Usage in Validator

Method 1: Use your class directly

Method 2: Add to the rules list and use as a native rule


Testing

PHPValidator is fully tested using PestPHP.

Run all tests:

Or manually:

Tests are located in the /tests/Feature directory and include examples for:


Contributing

If you would like to contribute to PHPValidator, please follow our Contribution Guidelines.


Author

Kabirou ALASSANE - GitHub


Support

For questions or assistance with PHPValidator, you can contact me at https://kabiroualassane.link.


License

PHPValidator is open-source software licensed under the MIT license.


All versions of php-validator with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
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 blakvghost/php-validator contains the following files

Loading the files please wait ...