Download the PHP package julienlinard/php-validator without Composer

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

PHP Validator

🇬🇧 Read in English

💝 Support the project

If this package is useful to you, consider becoming a sponsor to support the development and maintenance of this open source project.


A modern and advanced validation system for PHP 8+ with custom rules, multilingual messages, conditional validation, and sanitization.

🚀 Installation

Requirements: PHP 8.0 or higher

⚡ Quick Start

Basic Usage

📋 Features

📖 Documentation

Available Rules

Required

Validates that a field is not empty.

Email

Validates that a field contains a valid email address.

Min / Max

Validates the minimum/maximum length of a string or value.

Numeric

Validates that a value is numeric.

URL

Validates that a field contains a valid URL.

In

Validates that a value is in a list of allowed values.

Pattern

Validates that a value matches a regex pattern.

Date

Validates that a field contains a valid date.

Boolean

Validates that a field is a boolean value. Accepts: true, false, 1, 0, "1", "0", "true", "false", "yes", "no", "on", "off".

Between

Validates that a value is between two numbers (for numeric) or has a length between two values (for strings).

File

Validates that a field is a valid uploaded file.

Image

Validates that a field is a valid image file. Automatically checks MIME type and uses getimagesize() to ensure it's a real image.

Size

Validates that a field has an exact size (for files: bytes, for strings: characters, for numbers: exact value).

Alpha

Validates that a field contains only letters (including accented characters).

Alpha Num

Validates that a field contains only letters and numbers.

Alpha Dash

Validates that a field contains only letters, numbers, dashes and underscores.

Confirmed

Validates that a field has a matching confirmation field (e.g., password_confirmation).

IP Address

Validates that a field is a valid IP address.

JSON

Validates that a field contains a valid JSON string.

UUID

Validates that a field is a valid UUID (v1-v5).

Accepted

Validates that a field is accepted (yes, on, 1, true). Useful for checkboxes and terms acceptance.

Filled

Validates that a field has a value when present (different from required - allows null if field is not present).

Before / After

Validates that a date field is before or after another date.

Different / Same

Validates that a field is different from or same as another field.

Multilingual Support

The validator supports multiple languages (French, English, Spanish) out of the box.

Supported locales:

Custom Messages

You can customize error messages for specific fields and rules.

Sanitization

By default, the validator automatically sanitizes input data (trims strings, escapes HTML).

Custom Rules

You can create and register custom validation rules.

Integration with core-php

This package integrates seamlessly with core-php Forms.

📚 API Reference

Validator

validate(array $data, array $rules): ValidationResult

Validates data against rules.

setCustomMessages(array $messages): self

Sets custom error messages.

setSanitize(bool $sanitize): self

Enables or disables automatic sanitization.

registerRule(RuleInterface $rule): self

Registers a custom validation rule.

ValidationResult

isValid(): bool

Checks if validation passed.

hasErrors(): bool

Checks if validation failed.

getErrors(): array

Gets all errors grouped by field.

getFieldErrors(string $field): array

Gets errors for a specific field.

getFirstError(string $field): ?string

Gets the first error for a field.

getValidated(): array

Gets all validated and sanitized data.

getValidatedValue(string $field, mixed $default = null): mixed

Gets a validated value for a specific field.

📝 License

MIT License - See the LICENSE file for more details.

🤝 Contributing

Contributions are welcome! Feel free to open an issue or a pull request.

💝 Support

If this package is useful to you, consider becoming a sponsor to support the development and maintenance of this open source project.


Developed with ❤️ by Julien Linard


All versions of php-validator with dependencies

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

Loading the files please wait ...