string_validator library

Functions

blacklist(String str, String chars) String
remove characters that appear in the blacklist.
contains(String str, dynamic substring) bool
check if the string contains the substring
equals(String str, dynamic comparison) bool
check if the string matches the comparison
escape(String str) String
replace <, >, &, ' and " with HTML entities
isAfter(String str, [dynamic date]) bool
check if the string is a date that's after the specified date
isAlpha(String str) bool
check if the string contains only letters (a-zA-Z).
isAlphanumeric(String str) bool
check if the string contains only letters and numbers
isAscii(String str) bool
check if the string contains ASCII chars only
isBase64(String str) bool
check if a string is base64 encoded
isBefore(String str, [dynamic date]) bool
check if the string is a date that's before the specified date
isByteLength(String str, int min, [int? max]) bool
check if the string's length (in bytes) falls in a range.
isCreditCard(String str) bool
check if the string is a credit card
isDate(String str) bool
check if the string is a date
isDivisibleBy(String str, dynamic n) bool
check if the string is a number that's divisible by another
isEmail(String str) bool
check if the string is an email
isFloat(String str) bool
check if the string is a float
isFQDN(String str, [Map<String, Object>? options]) bool
check if the string is a fully qualified domain name (e.g. domain.com).
isFullWidth(String str) bool
check if the string contains any full-width chars
isHalfWidth(String str) bool
check if the string contains any half-width chars
isHexadecimal(String str) bool
check if the string is a hexadecimal number
isHexColor(String str) bool
check if the string is a hexadecimal color
isIn(String str, dynamic values) bool
check if the string is in an array of allowed values
isInt(String str) bool
check if the string is an integer
isIP(String str, [dynamic version]) bool
check if the string is an IP (version 4 or 6)
isISBN(String str, [dynamic version]) bool
check if the string is an ISBN (version 10 or 13)
isJson(dynamic str) bool
check if the string is valid JSON
isLength(String str, int min, [int? max]) bool
check if the string's length falls in a range If no max is given then any length above min is ok.
isLowercase(String str) bool
check if the string is lowercase
isMongoId(String str) bool
check if the string is a valid hex-encoded representation of a MongoDB ObjectId
isMultibyte(String str) bool
check if the string contains one or more multibyte chars
isNumeric(String str) bool
check if the string contains only numbers
isSurrogatePair(String str) bool
check if the string contains any surrogate pairs chars
isUppercase(String str) bool
check if the string is uppercase
isURL(String str, [Map<String, Object>? options]) bool
check if the string is a URL
isUUID(String str, [dynamic version]) bool
check if the string is a UUID (version 3, 4 or 5).
isVariableWidth(String str) bool
check if the string contains a mixture of full and half-width chars
ltrim(String str, [String? chars]) String
trim characters from the left-side of the input
matches(String str, dynamic pattern) bool
check if string matches the pattern.
normalizeEmail(String email, [Map<String, Object>? options]) String
canonicalize an email address.
rtrim(String str, [String? chars]) String
trim characters from the right-side of the input
stripLow(String str, [bool keep_new_lines = false]) String
remove characters with a numerical value < 32 and 127.
toBoolean(String str, [bool strict = false]) bool
convert the input to a boolean.
toDate(String str) DateTime?
convert the input to a date, or null if the input is not a date
toDouble(String str) double
convert the input to a float, or NAN if the input is not a float
toFloat(String str) double
convert the input to a float, or NAN if the input is not a float
toInt(String str, {int radix = 10}) num
convert the input to an integer, or NAN if the input is not an integer
toString(dynamic input) String
convert the input to a string
trim(String str, [String? chars]) String
trim characters (whitespace by default) from both sides of the input
whitelist(String str, String chars) String
remove characters that do not appear in the whitelist.