Name
Valid8r provides a validator to validate names to different kinds of configurations that can be either customized globally or provided on every validation.
import valid8r from '@c4code/valid8r';Configuration Options
import valid8r from '@c4code/valid8r';
const input: string = "Jonathan Wilson2";
// The configuration can be defaulted globally
valid8r.name(input, {
safe: false, // boolean
onlyFirst: false, // boolean
firstLast: true, // boolean
fullNameWithMiddle: false, // boolean
noSpChars: true, // boolean
minLen: 6, // number
maxLen: 99, // number
minLenPerWord: 4, // number
maxLenPerWord: 30, // number
allowNumbers: false, // boolean
properCapitalized: true, // boolean
noLeadingSpaces: true, // boolean
noTrailingSpaces: true, // boolean
noConsecutiveSpaces: true, // boolean
throwErrorsAs: "throw-all", // "throw-first" | "throw-last" | "throw-all",
/*
"throw-first" => Throws or returns the first error encountered,
"throw-last" => Throws or returns the last error encountered,
"throw-all" => Throws or returns all errors in a Array of string
*/
}); // the second argument is optionalBasic Usage
Safe handling
Error Messages
Error Message Options
Last updated