validateOrThrow method

void validateOrThrow(
  1. VxsSchema schema, {
  2. bool allowUnknown = true,
  3. int maxDepth = 8,
})

Throws VxsFormatException on the first validation issue.

Implementation

void validateOrThrow(
  VxsSchema schema, {
  bool allowUnknown = true,
  int maxDepth = 8,
}) {
  final issues = validate(
    schema,
    allowUnknown: allowUnknown,
    maxDepth: maxDepth,
  );
  if (issues.isNotEmpty) {
    throw VxsFormatException(
      issues.first.toString(),
      offset: issues.first.offset,
    );
  }
}