Skip to content

Commit

Permalink
fix max digits
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian Illies committed Mar 17, 2017
1 parent 8ff4c45 commit 439c821
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 7 deletions.
2 changes: 1 addition & 1 deletion e2e/web/public/fcsaNumber.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
if (decimalSeparator == null) {
decimalSeparator = '.';
}
validRegex = new RegExp("^-?\\d{0," + maxDigits + "}(\\" + decimalSeparator + "\\d*)?$");
validRegex = new RegExp("^-?\\d{0," + maxDigits + "}(\\.\\d*)?$");
return function(val) {
return validRegex.test(val);
};
Expand Down
5 changes: 1 addition & 4 deletions src/fcsaNumber.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ fcsaNumberModule.directive 'fcsaNumber',

makeMaxDecimals = (maxDecimals, decimalSeparator = '.') ->
if maxDecimals > 0
# regexString = "^-?\\d*\\#{decimalSeparator}?\\d{0,#{maxDecimals}}$"
# val contains a .
regexString = "^-?\\d*\\.?\\d{0,#{maxDecimals}}$"
else
regexString = "^-?\\d*$"
Expand All @@ -47,7 +45,7 @@ fcsaNumberModule.directive 'fcsaNumber',
(val, number) -> number >= minNumber

makeMaxDigits = (maxDigits, decimalSeparator = '.') ->
validRegex = new RegExp "^-?\\d{0,#{maxDigits}}(\\#{decimalSeparator}\\d*)?$"
validRegex = new RegExp "^-?\\d{0,#{maxDigits}}(\\.\\d*)?$"
(val) -> validRegex.test val

makeIsValid = (options) ->
Expand Down Expand Up @@ -107,7 +105,6 @@ fcsaNumberModule.directive 'fcsaNumber',
thousandSepRegEx = new RegExp "\\#{options.thousandSeparator}", 'g'

ngModelCtrl.$parsers.unshift (viewVal) ->
# remove thousand-separator
noCommasVal = viewVal.toString().replace thousandSepRegEx, ''
realNum = getRealNumber(noCommasVal, options.decimalSeparator)
if isValid(realNum) || !realNum
Expand Down
2 changes: 1 addition & 1 deletion src/fcsaNumber.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
if (decimalSeparator == null) {
decimalSeparator = '.';
}
validRegex = new RegExp("^-?\\d{0," + maxDigits + "}(\\" + decimalSeparator + "\\d*)?$");
validRegex = new RegExp("^-?\\d{0," + maxDigits + "}(\\.\\d*)?$");
return function(val) {
return validRegex.test(val);
};
Expand Down
2 changes: 1 addition & 1 deletion src/fcsaNumber.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 439c821

Please sign in to comment.