Validator.js: IsCurrency symbol validation error

Created on 4 May 2020  路  2Comments  路  Source: validatorjs/validator.js

Hi devs,

I'm trying use BRL currency in @IsCurrency options, but when I use this setting the validator fails:

{
    symbol: 'R$',
    require_symbol: true,
    allow_space_after_symbol: true,
    symbol_after_digits: false,
    allow_negatives: false,
    parens_for_negatives: false,
    negative_sign_before_digits: false,
    negative_sign_after_digits: false,
    allow_negative_sign_placeholder: false,
    thousands_separator: '.',
    decimal_separator: ',',
    allow_decimal: true,
    require_decimal: true,
    digits_after_decimal: [2],
    allow_space_after_digits: false,
}

Value: R$ 1.400,00

"statusCode": 400,
    "message": [
        "monthyMoneyGoal must be a currency"
    ],
    "error": "Bad Request"

But changing symbol to $ it works:

{
    symbol: '$',
    require_symbol: true,
    allow_space_after_symbol: true,
    symbol_after_digits: false,
    ...
}

Value: $ 1.400,00

"statusCode": 200,
    "message": [
        "Successful update"
    ],

Changing symbol to $R it unbelievably too works!

Why? Where is error?

PS: My app uses single quotes in Prettier Formatter

馃悰 bug

Most helpful comment

Hi @profnandaa ,
I was able reproduce it on a unit test. I would be glad of working on this issue if it still open.

All 2 comments

Thanks for raising! PR welcome.

Hi @profnandaa ,
I was able reproduce it on a unit test. I would be glad of working on this issue if it still open.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rathboma picture rathboma  路  4Comments

RPDeshaies picture RPDeshaies  路  4Comments

jaxkodex picture jaxkodex  路  3Comments

karladler picture karladler  路  3Comments

AtomicBorg picture AtomicBorg  路  3Comments