We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Nice library! I was looking forward to using it, but didn't find the only validator I need at the moment :)
I would like to validate digits with certain number of decimal places.
If decimal places set to 2: 0.12 -> Valid 0.123 -> Invalid
0.12
0.123
Maybe this can be helpful (my 2 decimal places validator):
export class DecimalValidator { static validate(formGroup: FormGroup): any { if (formGroup.pristine || !formGroup.value) { return undefined; } const TWO_DECIMAL_REGEXP = /^\d*(?:[.,]\d{1,2})?$/; formGroup.markAsTouched(); if (TWO_DECIMAL_REGEXP.test(formGroup.value)) { return undefined; } return { invalidDecimal: true }; } }
The text was updated successfully, but these errors were encountered:
Thanks, I will check it for the next release.
Sorry, something went wrong.
You can use a pattern validator for this like the one in your code.
pattern
No branches or pull requests
Nice library! I was looking forward to using it, but didn't find the only validator I need at the moment :)
I would like to validate digits with certain number of decimal places.
If decimal places set to 2:
0.12
-> Valid0.123
-> InvalidMaybe this can be helpful (my 2 decimal places validator):
The text was updated successfully, but these errors were encountered: