Download the PHP package timefrontiers/php-validator without Composer

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

TimeFrontiers PHP Validator

Request and configuration-boundary validation for PHP 8.5 and later. The package provides a fluent single-field API and deterministic bulk validation while keeping error maps stable and value-free.

Domain objects must still enforce their own invariants. This package does not perform database integrity checks, payment authorization, HTML purification, upload inspection, or output-context encoding.

Installation

The package requires PHP 8.5 or later and ext-mbstring.

Required action in 1.1.1. The minimum PHP version moved from 8.1 to 8.5. Despite the patch number this release is not installable on PHP 8.1-8.4. Confirm the runtime before upgrading; a consumer that cannot move to PHP 8.5 must pin 1.1.0 explicitly rather than ^1.1.

Entry points and result types

Entry point Result
Validator::field(string $field, mixed $value) FieldValidator; call validate() for ValidationResult
Validator::make(array $data, array $rules, array $messages = []) BulkValidationResult
Validator::validate(array $data, array $rules, array $messages = []) Validated values or ValidationException

ValidationResult::value() is the single-field accessor. Bulk access uses BulkValidationResult::validated() and get(); there is deliberately no bulk values() method.

Fluent single-field validation

bail(true)—the default—stops after the first failed rule. Use bail(false) to collect subsequent errors:

Custom callbacks must return exactly [bool $valid, mixed $normalized, ?string $error]. A callback must provide application-safe, value-free messages.

Malformed callback tuples throw LogicException rather than becoming input-validation failures.

Bulk validation grammar

String form

Rules are pipe-separated. Parameters follow the first colon and are comma-separated.

name:min,max maps to name([], min, max). String in:a,b,c and notIn:a,b,c treat the comma-separated values as options and use strict comparison.

Array form

Use bare strings for parameterless rules and nested tuples for parameterized rules:

Flat parameter arrays such as ['array', 1, 5] are ambiguous and throw ValidationConfigurationException; no entry is silently discarded.

Associative rules remain available where their parameter list is clear:

Prefer nested tuples when a rule itself accepts an array, especially in, notIn, name, username, and html.

Regular expressions

pattern and regex accept one complete delimited PCRE expression. Commas and pipes inside the expression are data, and a pipe after the closing modifiers starts the next validation rule.

The delimiter must be non-alphanumeric, non-backslash, and non-whitespace. Invalid or unclosed patterns throw a configuration exception without exposing the pattern. JavaScript-only trailing g and y modifiers are removed for backward compatibility; all other modifiers must be supported PCRE modifiers.

Required, nullable, and dotted fields

Dot notation reads nested input, while the validated result remains keyed by the configured dotted field name:

Only passing fields appear in validated().

Result and error contracts

Both result types and ValidationException expose errors as:

ValidationResult

BulkValidationResult

A bulk custom message is configured per field and replaces that field's collected rule messages:

Exceptions

Unknown rules, malformed grammar, invalid regular expressions, and incorrect bulk parameters throw ValidationConfigurationException, which extends InvalidArgumentException. Messages may identify the configured field and rule but never include the submitted value or full regex.

Valid policies that reject input populate the error map. Validator::validate(), validateOrFail(), and throwIfFailed() throw ValidationException with code 422:

Rule reference

Category Rules and aliases
Presence required, nullable
Strings name, username, email, password, phone/tel, url, ip, text, html, slug, uuid, json, hex, color, alpha, alphanumeric/alnum, pattern/regex
Numbers int/integer, float/decimal/number, boolean/bool
Date/time date, time, datetime
Choices in/option, notIn/not_in
Arrays array; fluent arrayOf()
Length min, max, length, between
Special creditcard, countryCode/country_code, currencyCode/currency_code; fluent fileExtension()

date($format, ...) accepts only input and bounds that exactly match $format, rejects parse warnings, and normalizes passing values to Y-m-d.

time() accepts complete H:i, H:i:s, g:i a, or g:i:s a strings and normalizes to H:i:s. datetime() accepts exactly Y-m-d H:i:s. Timezone-aware domain policies belong in application value objects after validation.

arrayOf() can invoke only an explicit non-recursive allowlist of item-safe rules. It rejects arrayOf itself, creditcard, unknown methods, and malformed item-rule parameters.

Normalization and security boundary

Several rules normalize values: whitespace may be trimmed, email is lowercased, booleans and numbers are typed, dates/times are normalized, and colors gain a canonical # prefix.

The following limitations are intentional:

The package never performs HTML output encoding for a specific sink, SQL escaping, payment authorization, database uniqueness checks, provider verification, or business-policy enforcement.

Upgrading from 1.0.x

The valid fluent API, Validator::make(), Validator::validate(), result methods, custom field messages, error maps, and dotted lookup remain compatible. Review these deliberate corrections:

  1. PHP 8.5 is required from 1.1.1. 1.1.0 accepted PHP 8.1 and later; 1.1.1 does not. This is the one change that can stop an upgrade outright.
  2. Unknown rules now throw instead of being skipped.
  3. Flat parameter arrays must become nested tuples.
  4. Bulk access is validated() and get(); stale values() and value($field) examples never represented the source API.
  5. Date, time, and datetime parsing is exact and may reject formerly flexible input.
  6. URL validation rejects non-HTTP(S) schemes.
  7. Regex rules use the deterministic delimited-expression lexer.
  8. Choice failures no longer list configured options in user-facing messages.
  9. Documentation no longer describes text(), html(), filename, code-shape, or Luhn checks as general security sanitization.

There is no legacy parser mode because it would retain fail-open behavior.

Development

The package does not commit a Composer lock file. Release verification must include a clean dependency resolution, PHPUnit on PHP 8.5 with lowest and current dependencies, PHPStan level max, syntax lint, and Composer audit.

License

MIT


All versions of php-validator with dependencies

PHP Build Version
Package Version
Requires ext-mbstring Version *
php Version >=8.5
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 timefrontiers/php-validator contains the following files

Loading the files please wait ...