Skip to content

Commit 39298d7

Browse files
Fixes issue #381 invalid day format for date validation rule
1 parent 9e6e70c commit 39298d7

File tree

5 files changed

+7
-5
lines changed

5 files changed

+7
-5
lines changed

dist/formulate.esm.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/formulate.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/formulate.umd.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/libs/utils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ export function regexForFormat (format) {
228228
MM: '(0[1-9]|1[012])',
229229
M: '([1-9]|1[012])',
230230
DD: '([012][0-9]|3[01])',
231-
D: '([012]?[1-9]|3[01])',
231+
D: '([012]?[0-9]|3[01])',
232232
YYYY: '\\d{4}',
233233
YY: '\\d{2}'
234234
}

test/unit/rules.test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,8 @@ describe('date', () => {
192192

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

195+
it('passes with date ending in zero', async () => expect(await rules.date({ value: '12/10/1987' }, 'MM/D/YYYY')).toBe(true))
196+
195197
it('fails with simple number and date format', async () => expect(await rules.date({ value: '1234' }, 'MM/DD/YYYY')).toBe(false))
196198

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

0 commit comments

Comments
 (0)