ISBN.fromJson constructor

ISBN.fromJson(
  1. Map<String, dynamic> map, {
  2. String? key,
})

Returns a valid ISBN object.

If key is null ISBN.key is used to get it's corresponding value in map.

Throws InvalidValueException if map's value is not a valid ISBN number.

Implementation

factory ISBN.fromJson(Map<String, dynamic> map, {String? key}) {
  final flatMap = flattenMap(map);
  final value = flatMap[key ?? ISBN.key].toString();
  return ISBN(value.toString());
}