@widergy/web-utils
Version:
Utility GO! Web utils
221 lines (220 loc) • 14.8 kB
TypeScript
import { AllValuesInterface, DocumentValidationInterface } from './constants/commonInterfaces';
export interface PatternInterface {
(val: string): string | undefined;
}
export declare const regexValidations: (regExps: Array<Record<"expression" | "error", string>>) => (value?: string) => string | undefined;
export declare const validDateCreditCard: (errorMessage: string) => (val: string) => string | undefined;
export interface CustomDateValidations {
timeZone: string | undefined;
avoidWeekends: {
active: boolean;
weekendDays: Array<number>;
errorMessage: string;
};
avoidHolidays: {
active: boolean;
holidays: Array<string>;
errorMessage: string;
};
avoidSameOrBeforeDates: {
active: boolean;
errorMessage: string;
};
avoidDaysAfter: {
active: boolean;
days: number;
errorMessage: string;
};
checkMaxHourThreshold: {
active: boolean;
hour: string;
errorMessage: string;
};
avoidWeekDaysWithValidation: {
active: boolean;
validate_field_id: string;
validate_field_values: any;
errorMessage: string;
};
avoidAfterPlusDays: {
active: boolean;
days: number;
errorMessage: string;
};
onlyPastMonth: {
active: boolean;
errorMessage: string;
};
}
export declare const checkCustomDateValidations: (dateValidations: CustomDateValidations, format: string) => (val: string, allValues: AllValuesInterface) => any;
export declare const validDate: (errorMessage: string) => (val: string) => string | undefined;
export declare const meetCuitRequirements: (cuit: string) => boolean;
export declare const required: (errorMessage: string) => (val: string) => string | undefined;
export declare const validateMinLength: (val: string | Array<any>, min: number) => boolean | string;
export declare const minLength: (min: number, errorMessage: string) => (val: string | Array<any>) => string | undefined;
export declare const attachmentMinLength: (min: number, errorMessage: string) => (val: any) => string | undefined;
export declare const validateMaxLength: (val: string, max: number) => boolean | string;
export declare const maxLength: (max: number, errorMessage: string) => (val: string) => string | undefined;
export declare const validateEquals: (val: string, length: number) => boolean | string;
export declare const getLastDigit: (val?: any) => number;
export declare const compareCBUDigits: (valueToCompare: number, cbuDigitToCompare: any) => boolean;
export declare const validateCBU: (cbuEntityKey: string, cbuNumberKey: string, errorMessage: string, invalidFormatErrorMessage: string) => (value?: any) => string | undefined;
export declare const lengthEquals: (length: number, errorMessage: string, onlyNumbers?: boolean) => (val: string) => string | undefined;
export declare const cuitValidate: (string: string, errorMessage: string) => (val: string) => string | undefined;
export declare const phoneLength: (length: number, errorMessage: string) => (val: string) => string | undefined;
export declare const pattern: (exp: RegExp, errorMessage: string) => (val: string) => string | undefined;
export declare const email: (errorMessage: string) => PatternInterface;
export declare const url: (errorMessage: string) => PatternInterface;
export declare const numericalFourDigits: (errorMessage: string) => PatternInterface;
export declare const numericalTenDigits: (errorMessage: string) => PatternInterface;
export declare const lettersAndSpaces: (errorMessage: string) => PatternInterface;
export declare const atLeastOneNumber: (errorMessage: string) => PatternInterface;
export declare const atLeastOneLowerCase: (errorMessage: string) => PatternInterface;
export declare const atLeastOneUpperCase: (errorMessage: string) => PatternInterface;
export declare const cuitFormat: (errorMessage: string) => (val: string) => string | undefined;
export declare const maxDate: (maxDate: string, errorMessage: string) => (val: string) => string | undefined;
export declare const minDate: (minDate: string, errorMessage: string) => (val: string) => string | undefined;
export declare const dateIsInRange: (lowBound: string, topBound: string, errorMessage: string) => (val: string) => string | undefined;
export declare const maxNum: (max: number, errorMessage: string) => (value: number) => string | undefined;
export declare const minNum: (min: number, errorMessage: string) => (value: number) => string | undefined;
export declare const minYear: (year: number, errorMessage: string) => (value: number) => string | undefined;
export declare const letterAndNumberRequired: (errorMessage: string) => (val: string) => string | undefined;
export declare const notEqual: (compareValue: string, errorMessage: string) => (value: string) => string | undefined;
export interface UserFormField {
auxiliary: boolean | undefined;
child_keys: string | undefined;
default_value: string | undefined;
description: string | undefined;
form_id: number | undefined;
format: string | undefined;
format_error_message: string | undefined;
id: number | undefined;
key: string | undefined;
logic_evaluation: string | undefined;
logic_evaluation_error_message: string | undefined;
order: number | undefined;
placeholder: string | undefined;
read_only: boolean | undefined;
required: boolean | undefined;
title: string | undefined;
tooltip: string | undefined;
type: string | undefined;
visibility_checkbox_field_id: number | undefined;
visibility_checkbox_field_value: string | undefined;
visibility_parent_field_key_id: number | undefined;
visibility_parent_field_option_value_id: number | undefined;
visibility_parent_field_option_values: any;
}
export declare const genKeyMap: (fields: Array<UserFormField>, idOrKey: string) => AllValuesInterface;
export declare const logicValidation: (keyMap: AllValuesInterface, logicEvaluation: string, errorMessage: string, idOrKey: string) => (_: any, allValues: AllValuesInterface) => string | undefined;
export interface PasswordMessages {
passwordRequired: string;
passwordExactLength: string;
passwordMinLength: string;
passwordMaxLength: string;
passwordRequireLetterAndNumber: string;
passwordStrength: string;
}
export declare const passwordValidations: (passMinLength: number, passMaxLength: number, requireNumberLetter: boolean, requireMultipleGroups: boolean, errorMessages: PasswordMessages, regexs: Array<RegExp>, minRequiredValidations: number) => ((val: string) => string | undefined)[];
export declare const validateDependantField: (dependantFieldName: string, errorMessage: string) => (val: string, allValues: AllValuesInterface) => string | undefined;
export declare const validateRequiredOnField: (requiredOnFieldName: string, errorMessage: string) => (val: string, allValues: AllValuesInterface) => string | undefined;
export declare const validateInvalidBins: (invalidBins: Array<string>, errorMessage: string) => (value: string) => string | boolean;
export declare const validateCreditCard: (errorMessage: string) => (value: string) => string | boolean;
export declare const validatePhoneWithChildKeys: (errorMessage: string) => (value: any) => string | undefined;
export interface CreditCardMessages {
cardNumberRequired: string;
invalidCardNumber: string;
holderNameRequired: string;
expiresRequired: string;
invalidExpires: string;
securityCodeRequired: string;
}
export interface AnimatedCreditCardValues {
expYear: string;
expMonth: string;
cardNumber: string;
securityCode: string;
holderName: string;
}
export interface AnimatedCreditCardErrors {
cardNumber: string;
holderName: string;
expires: string;
securityCode: string;
}
export interface SketchErrorMessages {
streetRequired: string;
neighborNumberRequired: string;
}
export interface SketchConfiguration {
child_keys: any;
}
export declare const validateSketch: (errorMessages: SketchErrorMessages, configuration: SketchConfiguration) => (value?: any) => string | boolean;
export declare const validateAnimatedCreditCard: (errorMessages: CreditCardMessages, childKeys: Array<string>, invalidBins?: Array<string>) => (value?: any) => string | boolean;
export declare const validateDocumentNumber: (errorMessage: string) => (value: string) => string | undefined;
export declare const validateRut: (value: string) => boolean;
export declare const documentValidation: (messages: DocumentValidationInterface, docTypeId: number, docTypeKey: string, docTypeMapping: any) => (value: string, allValues: AllValuesInterface) => any;
export declare const fileSignatureValidation: (file: File, admitedTypes: Array<string>, fileType: string) => Promise<boolean>;
export declare const fileSizeValidation: (file: File, maxFileSize: number) => boolean;
export declare const sameValue: (key: string, errorMessage: string) => (value: string, allValues: AllValuesInterface) => string | undefined;
export declare const differentValue: (key: string, errorMessage: string) => (value: string, allValues: AllValuesInterface) => string | undefined;
export declare const validateOnlyLettersAndNumbers: (errorMessage: string) => (value: string) => string | undefined;
export declare const validateBetweenValues: (min: number, max: number, errorMessage: string, hasSign: boolean) => (val: string) => string | undefined;
interface ValidateUtils {
regexValidations: (regExps: Array<Record<'expression' | 'error', string>>) => (value: string) => string | undefined;
atLeastOneNumber: (errorMessage: string) => PatternInterface;
atLeastOneLowerCase: (errorMessage: string) => PatternInterface;
atLeastOneUpperCase: (errorMessage: string) => PatternInterface;
validDateCreditCard: (errorMessage: string) => PatternInterface;
validDate: (errorMessage: string) => PatternInterface;
meetCuitRequirements: (cuit: string) => boolean;
required: (errorMessage: string) => PatternInterface;
validateMinLength: (val: string, min: number) => boolean | string;
attachmentMinLength: (min: number, errorMessage: string) => PatternInterface;
minLength: (min: number, errorMessage: string) => PatternInterface;
validateMaxLength: (val: string, max: number) => boolean | string;
maxLength: (max: number, errorMessage: string) => PatternInterface;
validateEquals: (val: string, length: number) => boolean | string;
lengthEquals: (length: number, errorMessage: string) => PatternInterface;
cuitValidate: (string: string, errorMessage: string) => PatternInterface;
logicValidation: (keyMap: AllValuesInterface, logicEvaluation: string, errorMessage: string, idOrKey: string) => (_: any, allValues: AllValuesInterface) => string | undefined;
genKeyMap: (fields: Array<UserFormField>, idOrKey: string) => AllValuesInterface | undefined;
phoneLength: (length: number, errorMessage: string) => PatternInterface;
pattern: (exp: any, errorMessage: string) => PatternInterface;
email: (errorMessage: string) => PatternInterface;
url: (errorMessage: string) => PatternInterface;
numericalFourDigits: (errorMessage: string) => PatternInterface;
numericalTenDigits: (errorMessage: string) => PatternInterface;
lettersAndSpaces: (errorMessage: string) => PatternInterface;
cuitFormat: (errorMessage: string) => PatternInterface;
maxDate: (maxDate: string, errorMessage: string) => PatternInterface;
minDate: (minDate: string, errorMessage: string) => PatternInterface;
dateIsInRange: (lowBound: string, topBound: string, errorMessage: string) => (val: string) => string | undefined;
maxNum: (max: number, errorMessage: string) => (value: number) => string | undefined;
minNum: (min: number, errorMessage: string) => (value: number) => string | undefined;
minYear: (year: number, errorMessage: string) => (value: number) => string | undefined;
letterAndNumberRequired: (errorMessage: string) => PatternInterface;
notEqual: (compareValue: string, errorMessage: string) => (value: string) => string | undefined;
validatePhoneWithChildKeys: (errorMessage: string) => PatternInterface;
passwordValidations: (passMinLength: number, passMaxLength: number, requireNumberLetter: boolean, requireMultipleGroups: boolean, errorMessages: PasswordMessages, regexs: Array<RegExp>, minRequiredValidations: number) => any;
validateDependantField: (dependantFieldValue: string, errorMessage: string) => (val: string, allValues: AllValuesInterface) => string | undefined;
validateRequiredOnField: (dependantFieldValue: string, errorMessage: string) => (val: string, allValues: AllValuesInterface) => string | undefined;
validateInvalidBins: (invalidBins: Array<string>, errorMessage: string) => (value: string) => string | boolean;
validateCreditCard: (errorMessage: string) => (value: string) => string | boolean;
validateAnimatedCreditCard: (errorMessages: CreditCardMessages, childKeys: Array<string>, invalidBins: Array<string>) => (value: AnimatedCreditCardValues) => string | boolean;
validateDocumentNumber: (errorMessage: string) => (value: string) => string | undefined;
validateSketch: (errorMessages: SketchErrorMessages, configuration: SketchConfiguration) => (value: Record<string, any>) => string | boolean;
validateRut: (value: string) => boolean;
fileSignatureValidation: (file: File, admitedTypes: Array<string>, fileType: string) => Promise<boolean>;
fileSizeValidation: (file: File, maxFileSize: number) => boolean;
sameValue: (key: string, errorMessage: string) => (value: string, allValues: AllValuesInterface) => string | undefined;
differentValue: (key: string, errorMessage: string) => (value: string, allValues: AllValuesInterface) => string | undefined;
documentValidation: (messages: DocumentValidationInterface, docTypeId: number, docTypeKey: string, docTypeMapping: any) => (value: string, allValues: AllValuesInterface) => string | undefined;
emailRegex: RegExp;
validateOnlyLettersAndNumbers: (errorMessage: string) => (value: string) => string | undefined;
validateBetweenValues: (min: number, max: number, errorMessage: string, hasSign: boolean) => (val: string) => undefined | string;
checkCustomDateValidations: (dateValidations: CustomDateValidations, format: string) => (val: string, allValues: AllValuesInterface) => undefined | string;
validateCBU: (cbuEntitykey: string, cbuNumberKey: string, errorMessage: string, invalidFormatErrorMessage: string) => (value: Record<'cbuEntityKey' | 'cbuNumberKey', string>) => string | undefined;
}
declare const VALIDATE_UTILS: ValidateUtils;
export default VALIDATE_UTILS;