Skip to content

Commit

Permalink
fix: handle single values for the required if rule closes #2384
Browse files Browse the repository at this point in the history
  • Loading branch information
logaretm committed Sep 27, 2019
1 parent 0dbdb37 commit 66bf95c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/rules/required_if.ts
Expand Up @@ -8,7 +8,11 @@ const validate = (value: any, { target, values }: Record<string, any>) => {
let required;

if (values && values.length) {
// eslint-ignore-next-line
if (!Array.isArray(values) && typeof values === 'string') {
values = [values];
}

// eslint-disable-next-line
required = values.some((val: any) => val == String(target).trim());
} else {
required = !testEmpty(target);
Expand Down

0 comments on commit 66bf95c

Please sign in to comment.