Skip to content

Commit

Permalink
chore(EasyField): update internal validators
Browse files Browse the repository at this point in the history
  • Loading branch information
qiqiboy committed Mar 30, 2020
1 parent a9a51be commit c2071fa
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/EasyField/easyFieldHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ export const defaultValidators = [
],
['maxLength', ($value, len, props) => 'required' in props.$validError || ($value ?? '').length <= len * 1],
['minLength', ($value, len, props) => 'required' in props.$validError || ($value ?? '').length >= len * 1],
['max', ($value, limit, props) => 'required' in props.$validError || $value * 1 <= limit * 1],
['min', ($value, limit, props) => 'required' in props.$validError || $value * 1 >= limit * 1],
['max', ($value, limit, props) => 'required' in props.$validError || ($value ?? 0) * 1 <= limit * 1],
['min', ($value, limit, props) => 'required' in props.$validError || ($value ?? 0) * 1 >= limit * 1],
['pattern', ($value, regexp, props) => 'required' in props.$validError || regexp.test($value)],
['enum', ($value, enumeration, props) => 'required' in props.$validError || enumeration.indexOf($value) > -1],
['checker', ($value, checker, props) => 'required' in props.$validError || checker($value, props)]
Expand Down
2 changes: 1 addition & 1 deletion tests/EasyField.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ describe('built-in validators', () => {

expect(getFormutil().$errors).toEqual({
a: { min: 'Error input: min' },
b: { max: 'Error input: max', min: 'Error input: min' }
b: { min: 'Error input: min' }
});

userEvent.type(getByTestId('input'), '1'); // 11
Expand Down

0 comments on commit c2071fa

Please sign in to comment.