From b96bf5bd9023237928d5a53842a898a0cabc909f Mon Sep 17 00:00:00 2001 From: Nick Graef <1031317+ngraef@users.noreply.github.com> Date: Tue, 7 Sep 2021 17:55:14 -0500 Subject: [PATCH] add typing for currency rule --- index.d.ts | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/index.d.ts b/index.d.ts index 6da5561..6db6ad0 100644 --- a/index.d.ts +++ b/index.d.ts @@ -4,6 +4,7 @@ export type ValidationRuleName = | "array" | "boolean" | "class" + | "currency" | "custom" | "date" | "email" @@ -103,6 +104,41 @@ export interface RuleClass extends RuleCustom { instanceOf?: T; } +/** + * Validation schema definition for "currency" built-in validator + * @see https://github.com/icebob/fastest-validator#currency + */ +export interface RuleCurrency extends RuleCustom { + /** + * Name of built-in validator + */ + type: "currency"; + /** + * The currency symbol expected in string (as prefix) + * @default null + */ + currencySymbol?: string; + /** + * Toggle to make the currency symbol optional in string + * @default false + */ + symbolOptional?: boolean; + /** + * Thousand place separator character + * @default ',' + */ + thousandSeparator?: string; + /** + * Decimal place character + * @default '.' + */ + decimalSeparator?: string; + /** + * Custom regular expression to validate currency strings + */ + customRegex?: RegExp | string; +} + /** * Validation schema definition for "date" built-in validator * @see https://github.com/icebob/fastest-validator#date @@ -754,6 +790,7 @@ export type ValidationRuleObject = | RuleArray | RuleBoolean | RuleClass + | RuleCurrency | RuleDate | RuleEmail | RuleEqual