Skip to content

Commit a9e2651

Browse files
Add GBP, Euro and Yen support for currency rule (#383)
* Add GBP, Euro and Yen support for currency rule Allows for '$', '£', '€' and '¥' symbols to be used in the currency rule instead of just '$'. * Update currency docs to reflect alowed symbols Changes currency documentation in README.md from being dollar-specific to specifying allowed currances
1 parent 0f77e6e commit a9e2651

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ Must be a valid credit card expiration date. Ex. 10/18 or 10/2018
316316
Must be a valid credit card number. Ex. 4242424242424242 or 4242 4242 4242 4242
317317

318318
#### currency
319-
Must be a valid currency. Dollar signs and commas are optional. Ex. 4.25, $3000 or $3,245,525.12
319+
Must be a valid currency. Currency symbols ($, £, €, ¥) and commas are optional. Ex. 4.25, $3000 or £3,245,525.12
320320

321321
#### date
322322
Must be a date type <a href="https://momentjs.com/">momentjs</a> date.

src/simple-react-validator.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class SimpleReactValidator {
2828
boolean : {message: 'The :attribute must be a boolean.', rule: val => val === false || val === true},
2929
card_exp : {message: 'The :attribute must be a valid expiration date.', rule: val => this.helpers.testRegex(val,/^(([0]?[1-9]{1})|([1]{1}[0-2]{1}))\s?\/\s?(\d{2}|\d{4})$/)},
3030
card_num : {message: 'The :attribute must be a valid credit card number.', rule: val => this.helpers.testRegex(val,/^\d{4}\s?\d{4,6}\s?\d{4,5}\s?\d{0,8}$/)},
31-
currency : {message: 'The :attribute must be a valid currency.', rule: val => this.helpers.testRegex(val,/^\$?(\d{1,3})(\,?\d{3})*\.?\d{0,2}$/)},
31+
currency : {message: 'The :attribute must be a valid currency.', rule: val => this.helpers.testRegex(val,/^[\$£¥]?(\d{1,3})(\,?\d{3})*\.?\d{0,2}$/)},
3232
date : {message: 'The :attribute must be a date.', rule: val => this.helpers.momentInstalled() && moment.isMoment(val)},
3333
date_equals : {message: 'The :attribute must be on :date.', rule: (val, params) => this.helpers.momentInstalled() && moment.isMoment(val) && val.isSame(params[0], 'day'), messageReplace: (message, params) => message.replace(':date', params[0].format('MM/DD/YYYY'))},
3434
email : {message: 'The :attribute must be a valid email address.', rule: val => this.helpers.testRegex(val,/^[A-Z0-9.!#$%&'*+-/=?^_`{|}~]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i)},

0 commit comments

Comments
 (0)