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)

public offsetExists()
inherited from mini\Util\InstanceStore

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

public offsetGet()
inherited from mini\Util\InstanceStore

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

public offsetSet()
inherited from mini\Util\InstanceStore

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

public offsetUnset()
inherited from mini\Util\InstanceStore

Remove an instance (mirrors WeakMap::offsetUnset)

public count()
inherited from mini\Util\InstanceStore

Get the number of stored instances

public getIterator()
inherited from mini\Util\InstanceStore

Get iterator for stored instances

public __set()
inherited from mini\Util\InstanceStore

Set instance by member access

public add()
inherited from mini\Util\InstanceStore

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

public delete()
inherited from mini\Util\InstanceStore

Delete instance (WeakMap-style method)

public keys()
inherited from mini\Util\InstanceStore

Get all stored keys

public values()
inherited from mini\Util\InstanceStore

Get all stored values

public getRequiredType()
inherited from mini\Util\InstanceStore

Get the required type for this store

Source

src/Validator/ValidatorStore.php:40-133