//#region modules/jb-validation/lib/types.d.ts export interface WithValidation { readonly isAutoValidationDisabled: boolean; readonly validation: ValidationHelper; required: boolean; readonly validity: ValidityState | undefined; validationMessage: string | null; clearValidationError: ClearValidationErrorCallback; checkValidity: () => boolean; reportValidity: () => boolean; } export type ValidationResultSummary = { isValid: boolean | null; message: string | null; }; export type ValidationResultItem = { isValid: boolean | null; message: string | null; validation: ValidationItem; }; export type ValidationResult = { validationList: ValidationResultItem[]; isAllValid: boolean; }; export type ValidatorFunction = (value: ValidationValue) => boolean | string | Promise; export type ValidationItem = { /** * @property key that will be used to identify validation item */ key?: any; /** * @property validation function or regex to match value with * @description if you want to use async validation you can return promise from validator function * @description if you leave it empty (undefined) it will always considered as invalid (used for manual error handler like server side validation or yup , zod,... validations) */ validator?: RegExp | ValidatorFunction; /** * @property error message that will be shown if validator return false or regex failed */ message: string; /** * @property type of error (category) its optional */ stateType?: keyof ValidityStateFlags; /** * @property defer validator execution until all non-deferred validation executed.(good for async validator) */ defer?: boolean; }; export type checkValidityParameters = { /** * @property showError determine if you want to show error in invalidate state or not. default is true */ showError?: boolean; /** * @property the value you want to check validation on its optional and if not set it will get from component value) */ value?: ValidationValue; }; export type ShowValidationErrorParameters = { message: string; }; export type ShowValidationErrorCallback = (error: ShowValidationErrorParameters) => void; export type ClearValidationErrorCallback = () => void; export type GetValueCallback = () => (ValidationValue | Promise); export type GetValueStringCallback = (value: ValidationValue) => string; export type GetValidationsCallback = () => ValidationItem[]; export type SetValidationResultCallback = (result: ValidationResult) => void; export type Callbacks = { getValue: GetValueCallback; getValueString: GetValueStringCallback; showValidationError: ShowValidationErrorCallback[]; clearValidationError: ClearValidationErrorCallback[]; getValidations: GetValidationsCallback[]; setValidationResult: SetValidationResultCallback[]; }; export type CallbacksInput = { [key in keyof Callbacks]?: Callbacks[key] extends Array ? Callbacks[key][0] : Callbacks[key]; }; //#endregion //#region modules/jb-validation/lib/validation-helper.d.ts export declare class ValidationHelper { #private; get resultSummary(): ValidationResultSummary | undefined; result: ValidationResult | null; /** * Clear the last validation result and any displayed validation error. */ reset(): void; constructor(callbacks: CallbacksInput); setCallbacks(callbacks: CallbacksInput): void; get list(): ValidationItem[]; set list(value: ValidationItem[]); /** * @description check if input validation list is fulfilled or not */ checkValidity(parameters?: checkValidityParameters): Promise>; /** * @description check if input validation list is fulfilled or not but will ignore async validations callbacks. */ checkValiditySync(input?: checkValidityParameters): ValidationResult; /** * @description this function will register a function as validation getter sp on each validation check it will call getter function and check it's returned validation * @public */ addValidationListGetter(func: GetValidationsCallback): void; } //#endregion //#region modules/jb-validation/lib/utils.d.ts /** * @description check sync validations of value (will ignore async validations) * @param list list of validation * @param value the value you want to check it's validation * @param getValueString function that return value in string */ export declare function checkValueValidationSync(list: ValidationItem[], value: ValidationValue, getValueString: GetValueStringCallback): ValidationResult; /** * @description check validations of value * @param list list of validation * @param value the value you want to check it's validation * @param getValueString function that return value in string */ export declare function checkValueValidationAsync(list: ValidationItem[], value: ValidationValue, getValueString: GetValueStringCallback): Promise>; export declare function checkValueValidation(list: ValidationItem[], value: ValidationValue, getValueString: GetValueStringCallback): { syncValidationResult: ValidationResult; asyncList: Promise>[]; }; /** * @description check single validation item */ export declare function checkValidation(value: ValidationValue, validation: ValidationItem, getValueString: GetValueStringCallback): Promise> | ValidationResultItem; type checkValidatorFunctionRes = { isValid: boolean; message: string | null; }; /** * * @param validator validator function * @param value the value you want to send to validator * @returns */ export declare function checkValidator(validator: ValidatorFunction, value: ValidationValue): Promise | checkValidatorFunctionRes; //#endregion //# sourceMappingURL=jb-validation.d.ts.map