requireSchema function

void requireSchema(
  1. Json json, {
  2. String what = 'The document',
  3. int version = kSchemaVersion,
})

Throws an UnsupportedSchemaException (naming what) unless json's schema is version (default kSchemaVersion).

Implementation

void requireSchema(Json json, {String what = 'The document', int version = kSchemaVersion}) {
  final schema = json['schema'];
  if (schema is num && schema == version) return;
  throw UnsupportedSchemaException(schema, what: what);
}