requireBool function

bool requireBool(
  1. CrossmintJsonMap map,
  2. String key, {
  3. required String entity,
})

Returns the boolean at key in map, or throws a typed CrossmintDeserializationException naming entity and key.

Implementation

bool requireBool(CrossmintJsonMap map, String key, {required String entity}) {
  final Object? value = map[key];
  if (value is bool) {
    return value;
  }
  throw CrossmintDeserializationException(
    'Expected boolean for "$key" while parsing $entity.',
    entity: entity,
    field: key,
    cause: map,
  );
}