Download the PHP package rasuvaeff/yii3-respect-validation without Composer

On this page you can find all versions of the php package rasuvaeff/yii3-respect-validation. 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 yii3-respect-validation

rasuvaeff/yii3-respect-validation

Stable Version Total Downloads Build Static analysis Psalm level PHP Русская версия

Bridge exposing Respect/Validation rules as native yiisoft/validator rules — usable as a #[RespectRule] attribute on a FormModel/DTO property, alongside built-in Yii3 rules, with results going through the same Result/Yiisoft\Translator pipeline.

Using an AI coding assistant? llms.txt contains a compact API reference you can share with the model. Contributors: see AGENTS.md.

Requirements

Requirement Version
PHP >=8.5 (required by respect/validation ^3.1)
respect/validation ^3.1
yiisoft/validator ^2.6
yiisoft/translator ^3.0

Installation

Usage

v:: fluent chains work too, since RespectRule accepts either a Respect\Validation\Validator instance or a Respect\Validation\ValidatorBuilder (what v:: returns):

PHP attribute arguments must be constant expressions, so only rule chains built from new Validator(...) calls work directly in #[RespectRule(...)]. v:: chains need to be built outside the attribute and passed to the constructor.

Fluent v:: chains on a model: RulesProviderInterface

To keep the fluent v:: API without giving up per-model rule declarations, implement Yiisoft\Validator\RulesProviderInterface instead of attributes — getRules() is ordinary runtime code, so any chain works there:

Both styles produce identical results and can be mixed: attributes for simple new-constructible chains, getRules() where the fluent builder is worth it.

Skip / conditional validation

RespectRule implements the same SkipOnEmptyInterface / SkipOnErrorInterface / WhenInterface contracts as built-in rules:

Messages and translation

Respect's own message templates (e.g. {{subject}} must be a string) are rendered by the handler itself — not by Respect's internal InterpolationRenderer (which needs symfony/translation-contracts) — so the whole app keeps a single i18n pipeline: Yiisoft\Translator.

By default (no TranslatorInterface wired), messages are rendered in English via RespectMessageFormatter.

A complete Russian catalog ships with the package (messages/ru/, all ~310 Respect template strings). To activate it, install the PHP message reader and set the application locale to ru — the shipped config/di.php picks it up automatically:

A build-time test (RussianMessageCatalogTest) pins every catalog key to the installed respect/validation templates, so an upstream wording change turns CI red instead of silently dropping translations.

For other locales, add your own catalog next to the app (same category):

DI configuration (Yii3)

This package ships config/di.php + config/params.php via config-plugin — installing it alongside yiisoft/config is enough to get RespectRuleHandler wired with a dedicated translation category (yii3-respect-validation) using a {{placeholder}}-aware RespectMessageFormatter (Respect templates use double braces, not the ICU syntax the rest of yiisoft/validator uses — mixing the two under one formatter would break placeholder substitution for one of them).

The category reads the bundled messages/{locale} catalogs when yiisoft/translator-message-php is installed; without it, messages pass through untranslated (English template text).

Override the category name in your application config if needed:

Components

RespectRule

Parameter Type Default Description
validator Respect\Validation\Validator\|Respect\Validation\ValidatorBuilder The wrapped Respect rule/chain.
skipOnEmpty bool\|callable\|null null Skip on empty, see SkipOnEmptyInterface.
skipOnError bool false Skip on prior error, see SkipOnErrorInterface.
when ?Closure null Conditional execution, see WhenInterface.

getOptions() (for frontend/client-side metadata export, per DumpedRuleInterface) returns the wrapped validator's own $parameters property when present (e.g. Between exposes minValue/maxValue — the same values Respect uses to fill in its own templates), plus skipOnEmpty/skipOnError. No JavaScript runtime is shipped — Respect has ~150 rules, many encoding arbitrary PHP logic (Luhn checksums, locale-aware checks, Callback closures); porting all of them to JS is not realistic to maintain, so this package limits itself to the same metadata-export mechanism yiisoft/validator itself uses.

RespectRuleHandler

Parameter Type Default Description
translator ?Yiisoft\Translator\TranslatorInterface null If null, falls back to RespectMessageFormatter directly (English only).
translationCategory string 'yii3-respect-validation' Category looked up on $translator.

Walks the Respect\Validation\Result tree returned by evaluate() and emits one Yiisoft\Validator\Result error per failed leaf (and per failed adjacent message), each with its own valuePath built from Respect's own nested Path (e.g. failing array keys under Each/KeySet).

RespectMessageFormatter

Yiisoft\Translator\MessageFormatterInterface implementation substituting Respect's own {{param}} placeholder syntax (not ICU). Register it on a Yiisoft\Translator\CategorySource — see DI configuration.

Security

Examples

See examples/ for a runnable script.

Script Shows Needs server?
validate-form.php Wrapping Respect rules on a DTO, reading Result errors no

Development

No PHP/Composer on the host — run in Docker via the composer:2 image:

Or with Make:

CI runs composer build on PHP 8.5 only — respect/validation requires php: >=8.5, so the usual 8.3/8.4/8.5 matrix does not apply to this package.

License

BSD-3-Clause


All versions of yii3-respect-validation with dependencies

PHP Build Version
Package Version
Requires php Version >=8.5
respect/validation Version ^3.1
yiisoft/translator Version ^3.0
yiisoft/validator Version ^2.6
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 rasuvaeff/yii3-respect-validation contains the following files

Loading the files please wait ...