devextreme
Version:
HTML5 JavaScript Component Suite for Responsive Web Development
248 lines (236 loc) • 9.27 kB
TypeScript
/**
* DevExtreme (ui/validation_rules.d.ts)
* Version: 22.1.9
* Build date: Tue Apr 18 2023
*
* Copyright (c) 2012 - 2023 Developer Express Inc. ALL RIGHTS RESERVED
* Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/
*/
/**
* @deprecated Attention! This type is for internal purposes only. If you used it previously, please submit a ticket to our {@link https://supportcenter.devexpress.com/ticket/create Support Center}. We will check if there is an alternative solution.
*/
export type ComparisonOperator = '!=' | '!==' | '<' | '<=' | '==' | '===' | '>' | '>=';
export interface ValidationCallbackData {
value?: any;
rule: any;
validator: any;
data?: any;
column?: any;
formItem?: any;
}
/**
* A custom validation rule that is checked asynchronously. Use async rules for server-side validation.
* @deprecated Attention! This type is for internal purposes only. If you used it previously, please submit a ticket to our {@link https://supportcenter.devexpress.com/ticket/create Support Center}. We will check if there is an alternative solution.
*/
export interface AsyncRule {
/**
* If true, the validationCallback is not executed for null, undefined, false, and empty strings.
*/
ignoreEmptyValue?: boolean;
/**
* Specifies the message that is shown if the rule is broken.
*/
message?: string;
/**
* Indicates whether the rule should always be checked for the target value or only when the value changes.
*/
reevaluate?: boolean;
/**
* Specifies the rule type. Set it to 'async' to use the AsyncRule.
*/
type: 'async';
/**
* A function that validates the target value.
*/
validationCallback?: ((options: ValidationCallbackData) => PromiseLike<any>);
}
/**
* A validation rule that demands that a validated editor has a value that is equal to a specified expression.
* @deprecated Attention! This type is for internal purposes only. If you used it previously, please submit a ticket to our {@link https://supportcenter.devexpress.com/ticket/create Support Center}. We will check if there is an alternative solution.
*/
export interface CompareRule {
/**
* Specifies the function whose return value is used for comparison with the validated value.
*/
comparisonTarget?: (() => any);
/**
* Specifies the operator to be used for comparing the validated value with the target.
*/
comparisonType?: ComparisonOperator;
/**
* If set to true, empty values are valid.
*/
ignoreEmptyValue?: boolean;
/**
* Specifies the message that is shown if the rule is broken.
*/
message?: string;
/**
* Specifies the rule type. Set it to 'compare' to use the CompareRule.
*/
type: 'compare';
}
/**
* A rule with custom validation logic.
* @deprecated Attention! This type is for internal purposes only. If you used it previously, please submit a ticket to our {@link https://supportcenter.devexpress.com/ticket/create Support Center}. We will check if there is an alternative solution.
*/
export interface CustomRule {
/**
* If true, the validationCallback is not executed for null, undefined, false, and empty strings.
*/
ignoreEmptyValue?: boolean;
/**
* Specifies the message that is shown if the rule is broken.
*/
message?: string;
/**
* Indicates whether the rule should be always checked for the target value or only when the target value changes.
*/
reevaluate?: boolean;
/**
* Specifies the rule type. Set it to 'custom' to use the CustomRule.
*/
type: 'custom';
/**
* A function that validates the target value.
*/
validationCallback?: ((options: ValidationCallbackData) => boolean);
}
/**
* A validation rule that demands that the validated field match the Email pattern.
* @deprecated Attention! This type is for internal purposes only. If you used it previously, please submit a ticket to our {@link https://supportcenter.devexpress.com/ticket/create Support Center}. We will check if there is an alternative solution.
*/
export interface EmailRule {
/**
* If set to true, empty values are valid.
*/
ignoreEmptyValue?: boolean;
/**
* Specifies the message that is shown if the rule is broken.
*/
message?: string;
/**
* Specifies the rule type. Set it to 'email' to use the EmailRule.
*/
type: 'email';
}
/**
* A validation rule that demands that the validated field has a numeric value.
* @deprecated Attention! This type is for internal purposes only. If you used it previously, please submit a ticket to our {@link https://supportcenter.devexpress.com/ticket/create Support Center}. We will check if there is an alternative solution.
*/
export interface NumericRule {
/**
* If set to true, empty values are valid.
*/
ignoreEmptyValue?: boolean;
/**
* Specifies the message that is shown if the rule is broken.
*/
message?: string;
/**
* Specifies the rule type. Set it to 'numeric' to use the NumericRule.
*/
type: 'numeric';
}
/**
* A validation rule that demands that the validated field match a specified pattern.
* @deprecated Attention! This type is for internal purposes only. If you used it previously, please submit a ticket to our {@link https://supportcenter.devexpress.com/ticket/create Support Center}. We will check if there is an alternative solution.
*/
export interface PatternRule {
/**
* If set to true, empty values are valid.
*/
ignoreEmptyValue?: boolean;
/**
* Specifies the message that is shown if the rule is broken.
*/
message?: string;
/**
* Specifies the regular expression that the validated value must match.
*/
pattern?: RegExp | string;
/**
* Specifies the rule type. Set it to 'pattern' to use the PatternRule.
*/
type: 'pattern';
}
/**
* A validation rule that demands the target value be within the specified value range (including the range's end points).
* @deprecated Attention! This type is for internal purposes only. If you used it previously, please submit a ticket to our {@link https://supportcenter.devexpress.com/ticket/create Support Center}. We will check if there is an alternative solution.
*/
export interface RangeRule {
/**
* If set to true, empty values are valid.
*/
ignoreEmptyValue?: boolean;
/**
* Specifies the maximum value allowed for the validated value.
*/
max?: Date | number;
/**
* Specifies the message that is shown if the rule is broken.
*/
message?: string;
/**
* Specifies the minimum value allowed for the validated value.
*/
min?: Date | number;
/**
* Indicates whether the rule should be always checked for the target value or only when the target value changes.
*/
reevaluate?: boolean;
/**
* Specifies the rule type. Set it to 'range' to use the RangeRule.
*/
type: 'range';
}
/**
* A validation rule that demands that a validated field has a value.
* @deprecated Attention! This type is for internal purposes only. If you used it previously, please submit a ticket to our {@link https://supportcenter.devexpress.com/ticket/create Support Center}. We will check if there is an alternative solution.
*/
export interface RequiredRule {
/**
* Specifies the message that is shown if the rule is broken.
*/
message?: string;
/**
* Indicates whether to remove the Space characters from the validated value.
*/
trim?: boolean;
/**
* Specifies the rule type. Set it to 'required' to use the RequiredRule.
*/
type: 'required';
}
/**
* A validation rule that demands the target value length be within the specified value range (including the range's end points).
* @deprecated Attention! This type is for internal purposes only. If you used it previously, please submit a ticket to our {@link https://supportcenter.devexpress.com/ticket/create Support Center}. We will check if there is an alternative solution.
*/
export interface StringLengthRule {
/**
* If set to true, empty values are valid.
*/
ignoreEmptyValue?: boolean;
/**
* Specifies the maximum length allowed for the validated value.
*/
max?: number;
/**
* Specifies the message that is shown if the rule is broken.
*/
message?: string;
/**
* Specifies the minimum length allowed for the validated value.
*/
min?: number;
/**
* Indicates whether or not to remove the Space characters from the validated value.
*/
trim?: boolean;
/**
* Specifies the rule type. Set it to 'stringLength' to use the StringLengthRule.
*/
type: 'stringLength';
}
export type ValidationRule = AsyncRule | CompareRule | CustomRule | EmailRule | NumericRule | PatternRule | RangeRule | RequiredRule | StringLengthRule;
export type ValidationRuleType = 'required' | 'numeric' | 'range' | 'stringLength' | 'custom' | 'compare' | 'pattern' | 'email' | 'async';