Skip to content

Commit

Permalink
Fixes issue #381 invalid day format for date validation rule
Browse files Browse the repository at this point in the history
  • Loading branch information
justin-schroeder committed Mar 2, 2021
1 parent 9e6e70c commit 39298d7
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion dist/formulate.esm.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/formulate.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/formulate.umd.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/libs/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ export function regexForFormat (format) {
MM: '(0[1-9]|1[012])',
M: '([1-9]|1[012])',
DD: '([012][0-9]|3[01])',
D: '([012]?[1-9]|3[01])',
D: '([012]?[0-9]|3[01])',
YYYY: '\\d{4}',
YY: '\\d{2}'
}
Expand Down
2 changes: 2 additions & 0 deletions test/unit/rules.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,8 @@ describe('date', () => {

it('passes with valid date format', async () => expect(await rules.date({ value: '12/10/1987' }, 'MM/DD/YYYY')).toBe(true))

it('passes with date ending in zero', async () => expect(await rules.date({ value: '12/10/1987' }, 'MM/D/YYYY')).toBe(true))

it('fails with simple number and date format', async () => expect(await rules.date({ value: '1234' }, 'MM/DD/YYYY')).toBe(false))

it('fails with only day of week', async () => expect(await rules.date({ value: 'saturday' })).toBe(false))
Expand Down

0 comments on commit 39298d7

Please sign in to comment.