enforce method

Map<String, dynamic> enforce(
  1. Map inputData, {
  2. String errorMessage = 'Invalid data.',
})

Validates input data, and throws an error if it is invalid.

Otherwise, the filtered data is returned.

Implementation

Map<String, dynamic> enforce(Map inputData,
    {String errorMessage = 'Invalid data.'}) {
  var result = check(inputData);

  if (result._errors.isNotEmpty) {
    throw ValidationException(errorMessage, errors: result._errors);
  }

  return result.data;
}