@@ -5,7 +5,7 @@ const v = new Validator();
55
66describe ( "Test rule: currency" , ( ) => {
77 it ( "should have decimal optional, and correctly placed if present" , ( ) => {
8- const check = v . compile ( { $$root : true , type : "currency" , ' currencySymbol' : '$' , ' symbolOptional' : true } ) ;
8+ const check = v . compile ( { $$root : true , type : "currency" , " currencySymbol" : "$" , " symbolOptional" : true } ) ;
99 expect ( check ( "$12.2" ) ) . toEqual ( true ) ;
1010 expect ( check ( "$12,222.2" ) ) . toEqual ( true ) ;
1111 expect ( check ( "$12,222" ) ) . toEqual ( true ) ;
@@ -14,7 +14,7 @@ describe("Test rule: currency", () => {
1414 } ) ;
1515
1616 it ( "should check thousand separator placement is correct" , ( ) => {
17- const check = v . compile ( { $$root : true , type : "currency" , ' currencySymbol' : '$' , ' symbolOptional' : true } ) ;
17+ const check = v . compile ( { $$root : true , type : "currency" , " currencySymbol" : "$" , " symbolOptional" : true } ) ;
1818 expect ( check ( "$12.2" ) ) . toEqual ( true ) ;
1919 expect ( check ( "$12,222.2" ) ) . toEqual ( true ) ;
2020 expect ( check ( "$122,222.2" ) ) . toEqual ( true ) ;
@@ -29,36 +29,36 @@ describe("Test rule: currency", () => {
2929 } ) ;
3030
3131 it ( "should not allow any other currency symbol, other than supplied in schema" , ( ) => {
32- let check = v . compile ( { $$root : true , type : "currency" , ' currencySymbol' : '$' , ' symbolOptional' : false } ) ;
32+ let check = v . compile ( { $$root : true , type : "currency" , " currencySymbol" : "$" , " symbolOptional" : false } ) ;
3333 expect ( check ( "$12.2" ) ) . toEqual ( true ) ;
3434 expect ( check ( "#12.2" ) ) . toEqual ( [ { "actual" : "#12.2" , "field" : undefined , "message" : "The '' must be a valid currency format" , "type" : "currency" } ] ) ;
3535 } ) ;
3636
3737 it ( "should keep currency symbol optional, if symbolOptional is true in schema" , ( ) => {
38- let check = v . compile ( { $$root : true , type : "currency" , ' currencySymbol' : '$' , ' symbolOptional' : true } ) ;
38+ let check = v . compile ( { $$root : true , type : "currency" , " currencySymbol" : "$" , " symbolOptional" : true } ) ;
3939 expect ( check ( "$12.2" ) ) . toEqual ( true ) ;
4040 expect ( check ( "12.2" ) ) . toEqual ( true ) ;
4141 expect ( check ( "#12.2" ) ) . toEqual ( [ { "actual" : "#12.2" , "field" : undefined , "message" : "The '' must be a valid currency format" , "type" : "currency" } ]
4242 ) ;
4343 } ) ;
4444
4545 it ( "should allow negative currencies" , ( ) => {
46- let check = v . compile ( { $$root : true , type : "currency" , ' currencySymbol' : '$' , ' symbolOptional' : true } ) ;
46+ let check = v . compile ( { $$root : true , type : "currency" , " currencySymbol" : "$" , " symbolOptional" : true } ) ;
4747 expect ( check ( "-12.2" ) ) . toEqual ( true ) ;
4848 expect ( check ( "$-12.2" ) ) . toEqual ( true ) ;
4949 expect ( check ( "-$12.2" ) ) . toEqual ( true ) ;
5050 expect ( check ( "-$-12.2" ) ) . toEqual ( [ { "actual" : "-$-12.2" , "field" : undefined , "message" : "The '' must be a valid currency format" , "type" : "currency" } ] ) ;
5151 } ) ;
5252
5353 it ( "should work correctly with supplied thousand and decimal separator" , ( ) => {
54- let check = v . compile ( { $$root : true , type : "currency" , ' currencySymbol' : '$' , ' symbolOptional' : true , ' thousandSeparator' : '.' , ' decimalSeparator' : ',' } ) ;
54+ let check = v . compile ( { $$root : true , type : "currency" , " currencySymbol" : "$" , " symbolOptional" : true , " thousandSeparator" : "." , " decimalSeparator" : "," } ) ;
5555 expect ( check ( "$12,2" ) ) . toEqual ( true ) ;
5656 expect ( check ( "$12.222" ) ) . toEqual ( true ) ;
5757 expect ( check ( "$12.222,2" ) ) . toEqual ( true ) ;
5858 expect ( check ( "$12,222.2" ) ) . toEqual ( [ { "actual" : "$12,222.2" , "field" : undefined , "message" : "The '' must be a valid currency format" , "type" : "currency" } ] ) ;
5959 } ) ;
6060 it ( "should work correctly with supplied regex pattern" , ( ) => {
61- let check = v . compile ( { $$root : true , type : "currency" , ' customRegex' : / 1 2 3 / g} ) ;
61+ let check = v . compile ( { $$root : true , type : "currency" , " customRegex" : / 1 2 3 / g} ) ;
6262 expect ( check ( "123" ) ) . toEqual ( true ) ;
6363 expect ( check ( "134" ) ) . toEqual ( [ { "actual" : "134" , "field" : undefined , "message" : "The '' must be a valid currency format" , "type" : "currency" } ] ) ;
6464 } ) ;
0 commit comments