Skip to content
Muhammet Şafak edited this page Jun 10, 2026 · 1 revision

FAQ

Does a failed validation throw an exception?

No. A failed validation is the normal false return of validation(), with the messages available from getError(). Exceptions are reserved for programming and configuration errors — see Exceptions.

Why did my rule throw UndefinedRuleException?

The rule name is not a built-in rule or a rule registered with extend() — usually a typo (integerr, requierd). Unknown rules fail loudly so a typo never silently skips validation. See Migration from 1.x.

Why doesn't my second validation() re-check earlier rules?

validation() consumes the rule queue. Each run validates only the rules queued since the last run. Queue rules again if you need them re-checked — see The Validation Lifecycle.

How do I get errors grouped by field?

getError() returns a flat list. Validate each field in its own run and key the results, or use self-describing custom messages. See Error Messages and the Recipes.

My optional field still fails — why?

optional only skips a field that is missing or null. An empty string ('') counts as present, so its rules still run. See Optional Fields.

How do I add a rule the library doesn't have?

Three ways: a callback rule for a one-off check, a mixed rule array, or extend() for a reusable named rule.

Can I validate arrays / nested data?

The value of a field can be an array — rules like array, in, min (element count) and startWith understand arrays. For deeply nested structures, validate each sub-array with its own setData() / validation() cycle (see Recipes → Validate a list).

Can I reuse one validator instance?

Yes — and you should. Configure the locale, labels, patterns and custom rules once; they survive every run. Only the rule queue and errors reset. See Recipes.

Which languages ship with the package?

English (en, default) and Turkish (tr). You can override messages or load your own language directory — see Localization.

Which PHP versions are supported?

PHP 8.1 and newer, with ext-mbstring. Older 7.x runtimes need the 1.x line.

Is this a PSR validation implementation?

No — there is no PSR for validation. The package is standalone and dependency-free.

Next

Clone this wiki locally