Skip to content

Commit 3952e32

Browse files
authored
Merge pull request #34 from QuickBase/skip_rule_checking_for_empty_non_required_fields
Skip rule checking for empty non required fields
2 parents a6d8c5b + de2cbc5 commit 3952e32

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ export default class ValidationComponent extends Component {
5050

5151
// Method to check rules on a spefific field
5252
_checkRules(fieldName, rules, value) {
53+
if (!value && !rules.required ) {
54+
return; // if value is empty AND its not required by the rules, no need to check any other rules
55+
}
5356
for (const key of Object.keys(rules)) {
5457
const isRuleFn = (typeof this.rules[key] == "function");
5558
const isRegExp = (this.rules[key] instanceof RegExp);

0 commit comments

Comments
 (0)