SchemaFixtureSuite constructor

SchemaFixtureSuite({
  1. required String name,
  2. JsonMap? schema,
  3. String? schemaPath,
  4. required List<SchemaFixtureCase> accept,
  5. required List<SchemaFixtureCase> reject,
})

Implementation

SchemaFixtureSuite({
  required this.name,
  this.schema,
  String? schemaPath,
  required this.accept,
  required this.reject,
}) : schemaPath = schemaPath ?? '$name.schema.json' {
  if (schema == null && this.schemaPath == '$name.schema.json') {
    throw ArgumentError.value(
      schemaPath,
      'schemaPath',
      'A suite without its own schema must name the schema it validates.',
    );
  }
  for (final (label, cases) in [('accept', accept), ('reject', reject)]) {
    final names = <String>{};
    for (final fixture in cases) {
      if (!names.add(fixture.name)) {
        throw ArgumentError('Duplicate $label fixture "${fixture.name}".');
      }
    }
  }
}