validateEvent function

HookedServiceEventListener<dynamic, dynamic, Service<Null, Null>> validateEvent(
  1. Validator validator,
  2. {String errorMessage = 'Invalid data.'}

Validates the data in, and sets the data to filtered data before continuing the service event.


HookedServiceEventListener validateEvent(Validator validator, {String errorMessage = 'Invalid data.'}) {
  return (HookedServiceEvent e) async {
    var result = await asyncApplyValidator(validator, as Map, (e.request?.app ??;

    if (result.errors.isNotEmpty) {
      throw GalileoHttpException.badRequest(message: errorMessage, errors: result.errors);