Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(v2): add leading zero validation to decimal fields #4697

Merged
merged 2 commits into from
Aug 31, 2022

Conversation

karrui
Copy link
Contributor

@karrui karrui commented Aug 26, 2022

Problem

Server validation will reject decimal fields with leading zeros. We should add client-side validation so users do not encounter cryptic submission errors.

Test cases

/^0[0-9]/.test('000') // true
/^0[0-9]/.test('00') // true
/^0[0-9]/.test('0') // false

/^0[0-9]/.test('001') // true
/^0[0-9]/.test('01') // true
/^0[0-9]/.test('1') // false

/^0[0-9]/.test('0010') // true
/^0[0-9]/.test('010') // true
/^0[0-9]/.test('10') // false

/^0[0-9]/.test('0.10') // false
/^0[0-9]/.test('0.010') // false
/^0[0-9]/.test('.10') // false
/^0[0-9]/.test('00.10') // true

Closes #4640

Solution

Breaking Changes

  • No - this PR is backwards compatible

Bug Fixes:

  • fix: add leading zero validation to decimal fields

Before & After Screenshots

Should have no change

@karrui karrui linked an issue Aug 26, 2022 that may be closed by this pull request
Copy link
Contributor

@wanlingt wanlingt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@karrui karrui requested a review from timotheeg August 26, 2022 09:14
Copy link
Contributor

@timotheeg timotheeg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@karrui karrui merged commit 50c8f92 into form-v2/develop Aug 31, 2022
@karrui karrui deleted the form-v2/fix-issue-4640 branch August 31, 2022 11:07
@justynoh justynoh mentioned this pull request Oct 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[1] Leading 0s in decimal field are not validated in the frontend
3 participants