mini\Validator\ValidatorStore class

Documentation

Registry for validator instances with auto-building from attributes

Stores validators by class name or custom identifiers, optionally scoped by purpose. Automatically builds validators from class attributes when accessing unknown classes.

Basic Usage

$store = Mini::$mini->get(ValidatorStore::class);

// Register core validator (no purpose)
$store->set(User::class, $coreValidator);

// Register purpose-specific validators
$store->set(User::class, $createValidator, Purpose::Create);
$store->set(User::class, $updateValidator, Purpose::Update);

// Custom purpose (string)
$store->set(User::class, $passwordResetValidator, 'password-reset');

Retrieval

$core = $store->get(User::class);
$create = $store->get(User::class, Purpose::Create);
$custom = $store->get(User::class, 'password-reset');

Inheritance

Extends: mini\Util\InstanceStore

Implements: ArrayAccess Countable IteratorAggregate Traversable mini\Contracts\MapInterface

Methods (18)

Documentation missing

Build cache key from class/identifier and optional purpose

Set a validator, optionally scoped by purpose

Check if a validator exists, optionally scoped by purpose

Get validator by key, auto-building from class attributes if needed

Magic getter - auto-builds from attributes if needed (core validator only)

Check if a key exists (mirrors WeakMap::offsetExists)

Get an instance by key (mirrors WeakMap::offsetGet)

Set an instance with type validation (mirrors WeakMap::offsetSet)

Remove an instance (mirrors WeakMap::offsetUnset)

Get the number of stored instances

Get iterator for stored instances

Set instance by member access

Add instance with type validation (throws if key already exists)

Delete instance (WeakMap-style method)

Get all stored keys

Get all stored values

Get the required type for this store

Source

src/Validator/ValidatorStore.php:40-133