Skip to content

Commit c8fa6f3

Browse files
committed
flip back the order of key check to get tests passing
1 parent 923facc commit c8fa6f3

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

json_annotation/lib/src/allowed_keys_helpers.dart

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,20 @@ void $checkAllowedKeys(Map map, Iterable<String> allowedKeys) {
2020
/// Should not be used directly.
2121
void $checkKeys(Map map,
2222
{List<String> allowedKeys, List<String> requiredKeys}) {
23-
if (requiredKeys != null) {
24-
var missingKeys = requiredKeys.where((k) => !map.keys.contains(k)).toList();
25-
if (missingKeys.isNotEmpty) {
26-
throw new MissingRequiredKeysException(missingKeys, map);
27-
}
28-
}
29-
3023
if (map != null && allowedKeys != null) {
3124
var invalidKeys =
3225
map.keys.cast<String>().where((k) => !allowedKeys.contains(k)).toList();
3326
if (invalidKeys.isNotEmpty) {
3427
throw new UnrecognizedKeysException(invalidKeys, map, allowedKeys);
3528
}
3629
}
30+
31+
if (requiredKeys != null) {
32+
var missingKeys = requiredKeys.where((k) => !map.keys.contains(k)).toList();
33+
if (missingKeys.isNotEmpty) {
34+
throw new MissingRequiredKeysException(missingKeys, map);
35+
}
36+
}
3737
}
3838

3939
/// Exception thrown if there are unrecognized keys in a JSON map that was

0 commit comments

Comments
 (0)