Neo Zero

validate

Pool

Zero-dependency string validation and sanitization - Tree-shakeable alternative to validator.js

$ lpm install @lpm.dev/neo.validate
66 exportsTypeScript

dist

Functions

isEmail
function isEmail(str: string, options?: EmailOptions): boolean

Validate email address (RFC 5322 practical regex) Uses practical 99.99% accurate regex instead of full RFC 5322 (full RFC regex is 6,343 chars and impractical)

ParameterTypeDescription
str
string- String to validate
optionsoptional
EmailOptions- Email validation options
isURL
function isURL(str: string, options?: URLOptions): boolean

Validate URL (RFC 3986) Supports http, https, ftp, file, data URLs

ParameterTypeDescription
str
string- String to validate
optionsoptional
URLOptions- URL validation options
isNumeric
function isNumeric(str: string, options?: NumericOptions): boolean

Check if string is numeric

ParameterTypeDescription
str
string- String to validate
optionsoptional
NumericOptions- Numeric validation options (min, max, gt, lt)
isInt
function isInt(str: string, options?: IntOptions): boolean

Check if string is an integer

ParameterTypeDescription
str
string- String to validate
optionsoptional
IntOptions- Integer validation options
isFloat
function isFloat(str: string, options?: FloatOptions): boolean

Check if string is a float

ParameterTypeDescription
str
string- String to validate
optionsoptional
FloatOptions- Float validation options
isDecimal
function isDecimal(str: string, options?: FloatOptions): boolean

Check if string is a decimal (must have decimal separator)

ParameterTypeDescription
str
string- String to validate
optionsoptional
FloatOptions- Float validation options
isAlpha
function isAlpha(str: string, locale?: string): boolean

Check if string contains only letters (a-z, A-Z)

ParameterTypeDescription
str
string- String to validate
localeoptional
string- Locale for character set (default: 'en-US')
isAlphanumeric
function isAlphanumeric(str: string, locale?: string): boolean

Check if string contains only letters and numbers

ParameterTypeDescription
str
string- String to validate
localeoptional
string- Locale for character set (default: 'en-US')
isLength
function isLength(str: string, options: LengthOptions): boolean

Check if string length is within range

ParameterTypeDescription
str
string- String to validate
options
LengthOptions- Length options (min, max)
isAscii
function isAscii(str: string): boolean

Check if string contains only ASCII characters

ParameterTypeDescription
str
string- String to validate
isLowercase
function isLowercase(str: string): boolean

Check if string is lowercase

ParameterTypeDescription
str
string- String to validate
isUppercase
function isUppercase(str: string): boolean

Check if string is uppercase

ParameterTypeDescription
str
string- String to validate
isIP
function isIP(str: string, version?: 4 | 6): boolean

Check if string is a valid IP address (IPv4 or IPv6)

ParameterTypeDescription
str
string- String to validate
versionoptional
4 | 6- IP version (4, 6, or undefined for both)
isMACAddress
function isMACAddress(str: string, options?: MACAddressOptions): boolean

Check if string is a valid MAC address

ParameterTypeDescription
str
string- String to validate
optionsoptional
MACAddressOptions- MAC address options
isPort
function isPort(str: string): boolean

Check if string is a valid port number

ParameterTypeDescription
str
string- String to validate
isJSON
function isJSON(str: string): boolean

Check if string is valid JSON

ParameterTypeDescription
str
string- String to validate
isBase64
function isBase64(str: string, options?: Base64Options): boolean

Check if string is valid Base64

ParameterTypeDescription
str
string- String to validate
optionsoptional
Base64Options- Base64 options
isHexadecimal
function isHexadecimal(str: string): boolean

Check if string is valid hexadecimal

ParameterTypeDescription
str
string- String to validate
isHexColor
function isHexColor(str: string): boolean

Check if string is valid hex color

ParameterTypeDescription
str
string- String to validate
isISO8601
function isISO8601(str: string): boolean

Check if string is valid ISO 8601 date

ParameterTypeDescription
str
string- String to validate
isRFC3339
function isRFC3339(str: string): boolean

Check if string is valid RFC 3339 date-time

ParameterTypeDescription
str
string- String to validate
isUUID
function isUUID(str: string, version?: 1 | 3 | 4 | 5): boolean

Check if string is a valid UUID

ParameterTypeDescription
str
string- String to validate
versionoptional
1 | 3 | 4 | 5- UUID version (1, 3, 4, 5, or undefined for any)
isISBN
function isISBN(str: string, version?: 10 | 13): boolean

Check if string is a valid ISBN

ParameterTypeDescription
str
string- String to validate
versionoptional
10 | 13- ISBN version (10, 13, or undefined for both)
isMongoId
function isMongoId(str: string): boolean

Check if string is a valid MongoDB ObjectId

ParameterTypeDescription
str
string- String to validate
isJWT
function isJWT(str: string): boolean

Check if string is a valid JSON Web Token (JWT)

ParameterTypeDescription
str
string- String to validate
isCreditCard
function isCreditCard(str: string): boolean

Check if string is a valid credit card number (Luhn algorithm) Validates using the Luhn algorithm (mod 10 checksum) Supports Visa, MasterCard, American Express, Discover, and more

ParameterTypeDescription
str
string- String to validate
escape
function escape(str: string): string

Escape HTML entities to prevent XSS attacks

ParameterTypeDescription
str
string- String to escape
unescape
function unescape(str: string): string

Unescape HTML entities

ParameterTypeDescription
str
string- String to unescape
trim
function trim(str: string, chars?: string): string

Trim whitespace from both ends of string

ParameterTypeDescription
str
string- String to trim
charsoptional
string- Characters to trim (default: whitespace)
ltrim
function ltrim(str: string, chars?: string): string

Trim whitespace from left side of string

ParameterTypeDescription
str
string- String to trim
charsoptional
string- Characters to trim (default: whitespace)
rtrim
function rtrim(str: string, chars?: string): string

Trim whitespace from right side of string

ParameterTypeDescription
str
string- String to trim
charsoptional
string- Characters to trim (default: whitespace)
normalizeEmail
function normalizeEmail(email: string, options?: NormalizeEmailOptions): string

Normalize email address

ParameterTypeDescription
email
string- Email to normalize
optionsoptional
NormalizeEmailOptions- Normalization options
stripLow
function stripLow(str: string, keepNewLines?: boolean): string

Remove control characters (ASCII 0-31 and 127)

ParameterTypeDescription
str
string- String to strip
keepNewLinesoptional
boolean- Keep newline characters (default: false)

dist

Functions

isEmail
function isEmail(str: string, options?: EmailOptions): boolean

Validate email address (RFC 5322 practical regex) Uses practical 99.99% accurate regex instead of full RFC 5322 (full RFC regex is 6,343 chars and impractical)

ParameterTypeDescription
str
string- String to validate
optionsoptional
EmailOptions- Email validation options
isURL
function isURL(str: string, options?: URLOptions): boolean

Validate URL (RFC 3986) Supports http, https, ftp, file, data URLs

ParameterTypeDescription
str
string- String to validate
optionsoptional
URLOptions- URL validation options
isNumeric
function isNumeric(str: string, options?: NumericOptions): boolean

Check if string is numeric

ParameterTypeDescription
str
string- String to validate
optionsoptional
NumericOptions- Numeric validation options (min, max, gt, lt)
isInt
function isInt(str: string, options?: IntOptions): boolean

Check if string is an integer

ParameterTypeDescription
str
string- String to validate
optionsoptional
IntOptions- Integer validation options
isFloat
function isFloat(str: string, options?: FloatOptions): boolean

Check if string is a float

ParameterTypeDescription
str
string- String to validate
optionsoptional
FloatOptions- Float validation options
isDecimal
function isDecimal(str: string, options?: FloatOptions): boolean

Check if string is a decimal (must have decimal separator)

ParameterTypeDescription
str
string- String to validate
optionsoptional
FloatOptions- Float validation options
isAlpha
function isAlpha(str: string, locale?: string): boolean

Check if string contains only letters (a-z, A-Z)

ParameterTypeDescription
str
string- String to validate
localeoptional
string- Locale for character set (default: 'en-US')
isAlphanumeric
function isAlphanumeric(str: string, locale?: string): boolean

Check if string contains only letters and numbers

ParameterTypeDescription
str
string- String to validate
localeoptional
string- Locale for character set (default: 'en-US')
isLength
function isLength(str: string, options: LengthOptions): boolean

Check if string length is within range

ParameterTypeDescription
str
string- String to validate
options
LengthOptions- Length options (min, max)
isAscii
function isAscii(str: string): boolean

Check if string contains only ASCII characters

ParameterTypeDescription
str
string- String to validate
isLowercase
function isLowercase(str: string): boolean

Check if string is lowercase

ParameterTypeDescription
str
string- String to validate
isUppercase
function isUppercase(str: string): boolean

Check if string is uppercase

ParameterTypeDescription
str
string- String to validate
isIP
function isIP(str: string, version?: 4 | 6): boolean

Check if string is a valid IP address (IPv4 or IPv6)

ParameterTypeDescription
str
string- String to validate
versionoptional
4 | 6- IP version (4, 6, or undefined for both)
isMACAddress
function isMACAddress(str: string, options?: MACAddressOptions): boolean

Check if string is a valid MAC address

ParameterTypeDescription
str
string- String to validate
optionsoptional
MACAddressOptions- MAC address options
isPort
function isPort(str: string): boolean

Check if string is a valid port number

ParameterTypeDescription
str
string- String to validate
isJSON
function isJSON(str: string): boolean

Check if string is valid JSON

ParameterTypeDescription
str
string- String to validate
isBase64
function isBase64(str: string, options?: Base64Options): boolean

Check if string is valid Base64

ParameterTypeDescription
str
string- String to validate
optionsoptional
Base64Options- Base64 options
isHexadecimal
function isHexadecimal(str: string): boolean

Check if string is valid hexadecimal

ParameterTypeDescription
str
string- String to validate
isHexColor
function isHexColor(str: string): boolean

Check if string is valid hex color

ParameterTypeDescription
str
string- String to validate
isISO8601
function isISO8601(str: string): boolean

Check if string is valid ISO 8601 date

ParameterTypeDescription
str
string- String to validate
isRFC3339
function isRFC3339(str: string): boolean

Check if string is valid RFC 3339 date-time

ParameterTypeDescription
str
string- String to validate
isUUID
function isUUID(str: string, version?: 1 | 3 | 4 | 5): boolean

Check if string is a valid UUID

ParameterTypeDescription
str
string- String to validate
versionoptional
1 | 3 | 4 | 5- UUID version (1, 3, 4, 5, or undefined for any)
isISBN
function isISBN(str: string, version?: 10 | 13): boolean

Check if string is a valid ISBN

ParameterTypeDescription
str
string- String to validate
versionoptional
10 | 13- ISBN version (10, 13, or undefined for both)
isMongoId
function isMongoId(str: string): boolean

Check if string is a valid MongoDB ObjectId

ParameterTypeDescription
str
string- String to validate
isJWT
function isJWT(str: string): boolean

Check if string is a valid JSON Web Token (JWT)

ParameterTypeDescription
str
string- String to validate
isCreditCard
function isCreditCard(str: string): boolean

Check if string is a valid credit card number (Luhn algorithm) Validates using the Luhn algorithm (mod 10 checksum) Supports Visa, MasterCard, American Express, Discover, and more

ParameterTypeDescription
str
string- String to validate
escape
function escape(str: string): string

Escape HTML entities to prevent XSS attacks

ParameterTypeDescription
str
string- String to escape
unescape
function unescape(str: string): string

Unescape HTML entities

ParameterTypeDescription
str
string- String to unescape
trim
function trim(str: string, chars?: string): string

Trim whitespace from both ends of string

ParameterTypeDescription
str
string- String to trim
charsoptional
string- Characters to trim (default: whitespace)
ltrim
function ltrim(str: string, chars?: string): string

Trim whitespace from left side of string

ParameterTypeDescription
str
string- String to trim
charsoptional
string- Characters to trim (default: whitespace)
rtrim
function rtrim(str: string, chars?: string): string

Trim whitespace from right side of string

ParameterTypeDescription
str
string- String to trim
charsoptional
string- Characters to trim (default: whitespace)
normalizeEmail
function normalizeEmail(email: string, options?: NormalizeEmailOptions): string

Normalize email address

ParameterTypeDescription
email
string- Email to normalize
optionsoptional
NormalizeEmailOptions- Normalization options
stripLow
function stripLow(str: string, keepNewLines?: boolean): string

Remove control characters (ASCII 0-31 and 127)

ParameterTypeDescription
str
string- String to strip
keepNewLinesoptional
boolean- Keep newline characters (default: false)
Unlimited AccessInstall as many Pool packages as you need.
Fund Real WorkEvery install you run sends revenue directly to the developer who built it.

Taxes calculated at checkout based on your location.

Weekly Installs
4
Version
1.0.0
Published
LicenseMIT
Size198.73 KB
Files13
Node version>= 18
TypeScriptYes