ng-devui
Version:
DevUI components based on Angular
80 lines (79 loc) • 3.03 kB
TypeScript
import { TemplateRef } from '@angular/core';
import { AsyncValidatorFn, ValidatorFn, Validators } from '@angular/forms';
import { Observable } from 'rxjs';
import { DValidators } from './validators';
export type DValidationErrorStrategy = 'pristine' | 'dirty';
export type DFormControlStatus = 'error' | 'pending' | 'success';
export type DValidatorFn = (value: any) => boolean | string | {
[key: string]: string;
} | null;
export type DAsyncValidatorFn = (value: any) => Observable<boolean | string | {
[key: string]: string;
} | null>;
export interface DValidateRule {
id?: string;
validator?: DValidatorFn | ValidatorFn;
message?: string | {
[key: string]: string;
} | TemplateRef<any>;
errorStrategy?: DValidationErrorStrategy;
priority?: number;
isNgValidator?: boolean;
validateLevel?: 'error' | 'warning';
[id: string]: boolean | number | string | {
[key: string]: string;
} | RegExp | DValidatorFn | ValidatorFn | undefined | TemplateRef<any>;
}
export interface DAsyncValidateRule {
id?: string;
validator?: DAsyncValidatorFn | AsyncValidatorFn;
message?: string | {
[key: string]: string;
} | TemplateRef<any>;
errorStrategy?: DValidationErrorStrategy;
priority?: number;
isNgValidator?: boolean;
validateLevel?: 'error' | 'warning';
[id: string]: boolean | number | string | {
[key: string]: string;
} | RegExp | DAsyncValidatorFn | AsyncValidatorFn | undefined | TemplateRef<any>;
}
export type DValidateRules = {
validators?: DValidateRule[];
asyncValidators?: DAsyncValidateRule[];
asyncDebounceTime?: number;
errorStrategy?: DValidationErrorStrategy;
message?: string | {
[key: string]: string;
} | TemplateRef<any>;
updateOn?: 'change' | 'blur' | 'submit';
messageShowType?: 'popover' | 'text' | 'none';
popPosition?: 'left' | 'right' | 'top' | 'bottom' | 'bottom-left' | 'bottom-right' | 'top-left' | 'top-right' | 'left-top' | 'left-bottom' | 'right-top' | 'right-bottom' | ('left' | 'right' | 'top' | 'bottom' | 'bottom-left' | 'bottom-right' | 'top-left' | 'top-right' | 'left-top' | 'left-bottom' | 'right-top' | 'right-bottom')[];
} | DValidateRule[];
export interface DValidateErrorStatus {
errorMessage: string | {
[key: string]: string;
} | null;
showError: boolean;
errors: {
[key: string]: any;
};
}
export declare const ruleReservedWords: string[];
export declare const dDefaultValidators: {
required: typeof Validators.required;
minlength: typeof Validators.minLength;
maxlength: typeof Validators.maxLength;
min: typeof Validators.min;
max: typeof Validators.max;
requiredTrue: typeof Validators.requiredTrue;
email: typeof Validators.email;
pattern: typeof Validators.pattern;
whitespace: typeof DValidators.whiteSpace;
};
export interface DPopConfig {
popMaxWidth?: number;
scrollElement?: Element;
zIndex?: number;
showAnimation?: boolean;
}