0
votes

I have a validator which works fine when running locally :

`export function currencyAmountValidator(control: AbstractControl) {

var passed = /^(\£)?([1-9]{1}[0-9]{0,2})(\,\d{3})(.\d{2})?$|^(\$)?([1-9]{1}[0-9]{0,2})(\d{3})(.\d{2})?$|^(0)?(.\d{2})?$|^(\$0)?(.\d{2})?$|^(\$.)(\d{2})?$/gm.test(control.value);

return passed ? null : { invalid: true }; } `

It allows entries like : 100, £100, £123.45, £1,300

However when I deploy to the server it doesn't allow the £ symbol at the start, but does allow a $. Why does it work differently when running locally and on server?

1
this regex does not allow £100 and £123.45, please check it on regex101Iftifar Taz
Does the $ simple work on your local? If not, then I would think that there may be a locality setting difference between your machine and the server.dmoore1181

1 Answers

0
votes

My solution was to use xA3 instead of £ in the regex, so this regex does what I want even after deployment to server :

/^(\xA3)?([1-9]{1}[0-9]{0,2})(\,\d{3})(.\d{2})?$|^(\xA3)?([1-9]{1}[0-9]{0,2})(\d{3})(.\d{2})?$|^(0)?(.\d{2})?$|^(\xA30)?(.\d{2})?$|^(\xA3.)(\d{2})?$/gm

Webpack (compiling of Angular into minified files) must have been messing around with the £