import { Observable } from 'rxjs'; import { Type, EventEmitter } from '@angular/core'; import { AbstractControl, ValueControlViewModel } from './control.types'; /** * @description 控件验证器错误 * * @export */ export declare class ControlValidatorError { /** * @description 是否验证成功,成功true,失败false * * @memberof ControlValidatorError */ success: boolean; /** * @description 验证失败信息 * * @memberof ControlValidatorError */ message: string; constructor(success?: boolean, message?: string); } /** * @description 控件验证器基类 * * @export * @abstract */ export declare abstract class ControlValidatorBase { /** * @description 关联控件 * * @memberof ControlValidatorBase */ control: AbstractControl; /** * @description 错误信息 * * @memberof ControlValidatorBase */ error: ControlValidatorError; /** * @description 验证器model * * @memberof ControlValidatorBase */ model: any; /** * 验证中 * * @memberof ControlValidatorBase */ validating: boolean; /** * @description 控件类型 * * @abstract * @memberof ControlValidatorBase */ abstract type: string; /** * @description 验证时机 * * @abstract * @memberof ControlValidatorBase */ abstract validateMoment: ControlValidateMoment; constructor(); } /** * @description 同步验证器 * * @export * @abstract */ export declare abstract class ControlValidator extends ControlValidatorBase { /** * @description 同步校验 * * @abstract * @returns 返回验证结果信息 * @memberof ControlValidator */ abstract validate(): ControlValidatorError; } /** * @description 异步验证器 * * @export * @abstract */ export declare abstract class ControlValidatorAsync extends ControlValidatorBase { /** * @description 异步校验 * * @abstract * @returns 一个可终结的ControlValidatorError的可观察对象 * @memberof ControlValidatorAsync */ abstract validateAsync(): Observable; constructor(); } /** * @description 控件验证器类型 * * @export * @enum {number} */ export declare enum ControlValidatorType { Required = "required", Unique = "unique", StringLength = "stringLength", RegularExpression = "regularExpression", RegularExpressionInternal = "regularExpressionInternal", DigitalRange = "digitalRange", DigitalType = "digitalType", FileTypeOfUpload = "fileTypeOfUpload", FileSizeOfUpload = "fileSizeOfUpload", AllowMultiOfUpload = "AllowMultiOfUpload", UnionCheck = "unionCheck" } /** * @description 控件验证时刻 * * @export * @enum {number} */ export declare enum ControlValidateMoment { Blur = 0, Input = 1, Change = 2 } /** * @description 抽象验证器编辑器 * * @export */ export interface AbstractValidatorEditor { /** * @description 关联控件 * * @memberof AbstractValidatorEditor */ control: AbstractControl; /** * @description 标题 * * @memberof AbstractValidatorEditor */ caption: string; /** * @description 名称 * * @memberof AbstractValidatorEditor */ validatorName: string; /** * @description 设置 * * @memberof AbstractValidatorEditor */ settings: any; /** * @description 验证器Model * * @memberof AbstractValidatorEditor */ model: ControlValidatorModel; /** * 初始化完成 * */ initComplete: boolean; /** * 值改变事件 * * @memberof AbstractValidatorEditor */ modelChange: EventEmitter>; } /** * @description 控件验证器model * * @export */ export declare class ControlValidatorModel { /** * @description 是否选中 * * @memberof ControlValidatorModel */ required: boolean; /** * @description 数据 * * @memberof ControlValidatorModel */ data: T; constructor(); } export interface DigitTypeValidatorValue { isInteger: boolean; isFloat: boolean; float: { decimalPlaces: number; }; } export interface FileUploadFileTypeValidatorValue { hasDocument: boolean; hasImage: boolean; hasCompressedPackage: boolean; } export interface FileUploadFileSizeValidatorValue { size: number; } export interface RegexValidatorModel { name: string; text: string; expression?: string; errorMessage?: string; validate?(value: any): ControlValidatorError; } export interface UnionCheckValidatorModel { unionId: string; unionRelation: string; errorMessage?: string; validate?(value: any): ControlValidatorError; } export interface UnionCheckRelation { name: string; operator: string; } /** * @description 验证器绑定model * * @export */ export interface ValidatorBindModel { /** * @description 验证器名称 * * @memberof ValidatorBindModel */ key: string; /** * @description 验证器类型 * * @memberof ValidatorBindModel */ value: Type; /** * @description 验证器生成工厂,用来生成验证器,返回值必须是ControlValidatorBase的一个实例 * * @memberof ValidatorBindModel */ factory?: Function; /** * @description 验证器构造函数的依赖项。如果验证器构造函数有依赖项,验证器工厂factory也不能为空 * * @memberof ValidatorBindModel */ deps?: any[]; }