validate method
Future<void>
validate(
- EngineContext context,
- Map<
String, String> rules, { - bool bail = false,
- Map<
String, String> ? messages,
override
Validates the query parameters against the provided rules.
This method uses a Validator to check the query parameters stored in
the EngineContext's query cache. If there are any validation errors,
a ValidationError is thrown.
- Parameters:
- context: The EngineContext containing the query parameters to validate.
- rules: A Map of validation rules to apply to the query 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,
);
// Validate the query parameters in the context's query cache.
final errors = validator.validate(context.queryCache);
// If there are any validation errors, throw a ValidationError.
if (errors.isNotEmpty) {
throw ValidationError(errors);
}
}