Normalization

To ensure data cleanliness before validation, the library applies a set of normalizers (configured in the normalizers() method of each rule).

Normalizers do not change the original data; they provide a normalized copy for the validation process.

Accessing Normalized Data

You can access a normalized version of the original data from the $result->normalized property.

Example:

use Norvica\Validation\Rule\Email;
use Norvica\Validation\Rule\Flag;

readonly class SubscriptionDto
{
    public function __construct(
        #[Email]
        public string $email,
        #[Flag(value: true)]
        public bool $consent,
    ) {}
}

$dto = new SubscriptionDto(' [email protected] ', ' yes ');

$result = $validator->validate($dto);
$result->normalized; // will contain: ['email' => '[email protected]', 'consent' => true]