validate method
Future<void>
validate(
- EngineContext context,
- Map<
String, String> rules, { - bool bail = false,
- Map<
String, String> ? messages,
override
Validates the URI parameters in the context against the provided rules.
Creates a Validator using the rules and validates the parameters in context.params.
If there are validation errors, it throws a ValidationError with the list of errors.
context - The engine context containing the parameters to validate.
rules - A map of validation rules to apply to the parameters.
Implementation
@override
Future<void> validate(
EngineContext context,
Map<String, String> rules, {
bool bail = false,
Map<String, String>? messages,
}) async {
final registry = requireValidationRegistry(context.container);
final validator = Validator.make(
rules,
registry: registry,
bail: bail,
messages: messages,
);
final errors = validator.validate(context.params);
if (errors.isNotEmpty) {
throw ValidationError(errors);
}
}