Skip to content

Commit 0db1e03

Browse files
authored
Merge pull request #270 from ngraef/fix/currency-type
add typing for currency rule
2 parents f4ec06e + b96bf5b commit 0db1e03

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

index.d.ts

+37
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ export type ValidationRuleName =
44
| "array"
55
| "boolean"
66
| "class"
7+
| "currency"
78
| "custom"
89
| "date"
910
| "email"
@@ -103,6 +104,41 @@ export interface RuleClass<T = any> extends RuleCustom {
103104
instanceOf?: T;
104105
}
105106

107+
/**
108+
* Validation schema definition for "currency" built-in validator
109+
* @see https://github.com/icebob/fastest-validator#currency
110+
*/
111+
export interface RuleCurrency extends RuleCustom {
112+
/**
113+
* Name of built-in validator
114+
*/
115+
type: "currency";
116+
/**
117+
* The currency symbol expected in string (as prefix)
118+
* @default null
119+
*/
120+
currencySymbol?: string;
121+
/**
122+
* Toggle to make the currency symbol optional in string
123+
* @default false
124+
*/
125+
symbolOptional?: boolean;
126+
/**
127+
* Thousand place separator character
128+
* @default ','
129+
*/
130+
thousandSeparator?: string;
131+
/**
132+
* Decimal place character
133+
* @default '.'
134+
*/
135+
decimalSeparator?: string;
136+
/**
137+
* Custom regular expression to validate currency strings
138+
*/
139+
customRegex?: RegExp | string;
140+
}
141+
106142
/**
107143
* Validation schema definition for "date" built-in validator
108144
* @see https://github.com/icebob/fastest-validator#date
@@ -754,6 +790,7 @@ export type ValidationRuleObject =
754790
| RuleArray
755791
| RuleBoolean
756792
| RuleClass
793+
| RuleCurrency
757794
| RuleDate
758795
| RuleEmail
759796
| RuleEqual

0 commit comments

Comments
 (0)