Updated validate null check
This commit is contained in:
parent
0ca3eb7e01
commit
834406de2d
3 changed files with 14 additions and 5 deletions
|
@ -1,5 +1,9 @@
|
||||||
# Change Log
|
# Change Log
|
||||||
|
|
||||||
|
## 8.0.1
|
||||||
|
|
||||||
|
* Fixed null check throwing exception
|
||||||
|
|
||||||
## 8.0.0
|
## 8.0.0
|
||||||
|
|
||||||
* Require Dart >= 3.0
|
* Require Dart >= 3.0
|
||||||
|
|
|
@ -162,7 +162,8 @@ class Validator extends Matcher {
|
||||||
var value = input[key];
|
var value = input[key];
|
||||||
var description = StringDescription("'$key': expected ");
|
var description = StringDescription("'$key': expected ");
|
||||||
|
|
||||||
for (var matcher in rules[key]!) {
|
var rulesList = rules[key] ?? [];
|
||||||
|
for (var matcher in rulesList) {
|
||||||
if (matcher is ContextValidator) {
|
if (matcher is ContextValidator) {
|
||||||
if (!matcher.validate(key, input)) {
|
if (!matcher.validate(key, input)) {
|
||||||
errors.add(matcher
|
errors.add(matcher
|
||||||
|
@ -175,7 +176,8 @@ class Validator extends Matcher {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (valid) {
|
if (valid) {
|
||||||
for (var matcher in rules[key]!) {
|
var rulesList = rules[key] ?? [];
|
||||||
|
for (var matcher in rulesList) {
|
||||||
try {
|
try {
|
||||||
if (matcher is Validator) {
|
if (matcher is Validator) {
|
||||||
var result = matcher.check(value as Map);
|
var result = matcher.check(value as Map);
|
||||||
|
@ -320,7 +322,10 @@ class Validator extends Matcher {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
rules[key]!.add(rule);
|
if (rules[key] == null) {
|
||||||
|
rules[key] = List.empty(growable: true);
|
||||||
|
}
|
||||||
|
rules[key]?.add(rule);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Adds all given [rules].
|
/// Adds all given [rules].
|
||||||
|
@ -333,7 +338,7 @@ class Validator extends Matcher {
|
||||||
/// Removes a [rule].
|
/// Removes a [rule].
|
||||||
void removeRule(String key, Matcher rule) {
|
void removeRule(String key, Matcher rule) {
|
||||||
if (rules.containsKey(key)) {
|
if (rules.containsKey(key)) {
|
||||||
rules[key]!.remove(rule);
|
rules[key]?.remove(rule);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
name: angel3_validate
|
name: angel3_validate
|
||||||
description: Cross-platform HTTP request body validator library based on `matcher`.
|
description: Cross-platform HTTP request body validator library based on `matcher`.
|
||||||
version: 8.0.0
|
version: 8.0.1
|
||||||
homepage: https://angel3-framework.web.app/
|
homepage: https://angel3-framework.web.app/
|
||||||
repository: https://github.com/dukefirehawk/angel/tree/master/packages/validate
|
repository: https://github.com/dukefirehawk/angel/tree/master/packages/validate
|
||||||
environment:
|
environment:
|
||||||
|
|
Loading…
Reference in a new issue