validateSchema<O> method
Check data with any schema and give its typed output.
Implementation
Future<O> validateSchema<O>(Schema<O> schema, Object? data) async {
ParseResult<O> result = schema.isAsync
? await schema.safeParseAsync(data, messages: Dox().messages)
: schema.safeParse(data, messages: Dox().messages);
if (!result.success) throw ValidationException(message: result.errors);
return result.value as O;
}