multiform-validator
Version:
Javascript library made to validate, several form fields, such as: email, images, phone, password, cpf etc.
31 lines (30 loc) • 962 B
TypeScript
import type { ValidateFunctions } from "./types";
interface OptionsParams {
minLength?: number;
maxLength?: number;
errorMsg?: (string | null)[];
}
/**
* @param surname
* @param minLength
* @param maxLength
* @param errorMsg
* @default minLength number: default: 1
* @default maxLength number: default: 25
* @example validateSurname('Jackson', { minLength: 3, maxLength: 25 });
* @info minLength cannot be greater than maxLength
* @description This function returns 6 errors in the following order,
*
* default:
*
* [
'Surname cannot be empty',
'Surname cannot contain numbers',
'Surname cannot contain special characters',
'This surname is not valid',
'Surname too big, try again',
];
* @returns An object with 'isValid' (boolean) and 'errorMsg' (string) properties.
*/
declare function validateSurname(surname: string, { minLength, maxLength, errorMsg }?: OptionsParams): ValidateFunctions;
export default validateSurname;