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 validate numbers #4

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

Fix validate numbers #4

wants to merge 6 commits into from

Conversation

breadbaker
Copy link

This fixes validation for numbers.

@breadbaker breadbaker added the bug Something isn't working label Aug 15, 2018
@@ -3,8 +3,10 @@ import { format } from 'd3-format'
const _isPositive = value => value && +value > 0
const _isPositiveOrZero = value => value && +value >= 0
const _isInteger = value => Math.round(+value) === +value
const _getNumber = value => value.replace(/,/g, '')
Copy link
Collaborator

Choose a reason for hiding this comment

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

strip dollar signs here too

@@ -132,7 +132,7 @@ export class Form extends Component {
return this.setState({ formModel })
}
const typedValue =
type === 'number' && !isNaN(value) ? Number(value) : value
type === 'number' && !isNaN(value.replace(/[,\$]/g, '')) ? Number(value.replace(/[,\$]/g, '')) : value
Copy link
Collaborator

Choose a reason for hiding this comment

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

probably should have a null check for value here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants