class ConstraintValidator (View source)

Helper class to abstract away wiring up symfony/validator and getting ValidationResult from validating symfony validator constraints.

Methods

public static 
validate(mixed $value, Constraint|array $constraints, string $fieldName = '')

Validate a value by a constraint

Details

static ValidationResult validate(mixed $value, Constraint|array $constraints, string $fieldName = '')

Validate a value by a constraint

Parameters

mixed $value
Constraint|array $constraints

a constraint or array of constraints to validate against

string $fieldName

The field name the value relates to, if relevant

Return Value

ValidationResult