Download the PHP package preflow/validation without Composer
On this page you can find all versions of the php package preflow/validation. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download preflow/validation
More information about preflow/validation
Files in preflow/validation
Package validation
Short Description Preflow validation — rule engine, built-in rules, error bags
License MIT
Informations about the package validation
preflow/validation
Rules for validating arrays and records. A rule is written as a string alias with parameters
(min:3, between:2,4) or as a ValidationRule instance.
Built-in rules
required, nullable, email, url, numeric, integer, min:n, max:n, between:min,max,
step:n, in:a,b, regex:/pattern/, confirmed, slug, slug:path.
step:n(since 0.46): the value must be a whole multiple ofncounted from 0 (step:0.5accepts2.5, refuses2.3). The check uses the decimal digits of the value and the step, not floats, so0.3is a multiple of0.1and large values stay exact; without bcmath a value too long for an integer is refused. Empty and non-numeric values pass;requiredandnumericjudge those. A step of 0 or below throws anInvalidArgumentException. The message isvalidation.stepwith:step.slug(since 0.52): a part of a web address, lowercasea-zand digits with single hyphens between them (ueber-uns). Umlauts, capitals, spaces, underscores and leading, trailing or double hyphens are refused.slug:pathalso allows single slashes between parts (docs/ueber-uns). Empty values pass. The messages arevalidation.slug.segmentandvalidation.slug.path.Slug::clean($text, path: false)makes text into a valid value (Über uns→ueber-uns,é→e; withpath: truesingle slashes stay); text with no a-z form gives''. Accents are dropped withext-intl'sNormalizer; without it only the letters ä, ö, ü, ß, æ, œ, ø, đ, ł and þ are converted.
Rules for a filled value only
new WhenFilled(...$rules) (since 0.46) runs the wrapped ValidationRule instances only when the value
is filled: null and '' pass, anything else answers with the first failing rule. Unlike nullable
it does not end the chain, so a required next to it still refuses an empty value:
numeric alone keeps refusing ''.
WhenFilled is used as an object only: it has no string alias, and a rule string naming its class would
build it without rules, so it would check nothing.
In an app
When preflow/validation is installed, the application binds RuleFactory and ValidatorFactory
in the container, and registers the rules in app/Rules/ (classes App\Rules\* with
#[RuleAlias('name')]). Since 0.66 this needs no database: it works without config/data.php
too, for forms that are not models. With config/data.php, models validate on save through the
same factory.
A package registers its own rule names with RuleFactory::register('name', RuleClass::class) in
its provider.
All versions of validation with dependencies
ext-mbstring Version *
preflow/view Version ^0.1 || @dev
preflow/i18n Version ^0.37 || @dev