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

Amount validation updated to match API maximum (99999999) #63

Merged
merged 2 commits into from
Jan 26, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions packages/embed/src/validation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -288,13 +288,18 @@ describe('validateNumber()', () => {
})

test('should return false if the number is too large', () => {
const options = {
const maxResult = validateNumber({
...defaultOptions,
value: 10000000,
value: 99999999,
callback: jest.fn(),
}
const valid = validateNumber(options)
expect(valid).toEqual(false)
})
expect(maxResult).toEqual(true)
const aboveMaxResult = validateNumber({
...defaultOptions,
value: 100000000,
callback: jest.fn(),
})
expect(aboveMaxResult).toEqual(false)
})

test('should return true if the number is a number as a string', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/embed/src/validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export const validateNumber = ({
callback?: (name: string, event: { message: string }) => void
}): boolean => {
const number = Number(value)
const valid = number >= 0 && number <= 999999
const valid = number >= 0 && number <= 99999999

if (canSkipValidation({ required, value }) || valid) {
return true
Expand Down