rules/index library

A library that provides a collection of text validation rules for various purposes.

This library exports a wide range of validators, including color validation, date validation, IT-related validation, language validation, list-related validation, magic validation, number validation, phone number validation, text validation, and URL validation.

Classes

Contains
checks if the input does contain the provided value;
ContainsAny
check if the value contain at lest one of String form the provided list
EndsWith
Validates that the trimmed input ends with end.
IsArabicChars
Validates that the input contains only Arabic letters, whitespace and Arabic-Indic digits (٠-٩).
IsArabicNum
Validates a positive integer in Latin digits, with no leading zero.
IsBool
Validates that the input is a boolean literal — true or false.
IsDate
Validates that the input is a date string DateTime.parse can read.
IsDateAfter
Validates that the input parses to a date strictly after date.
IsDateMillis
checks if the input is a valid date to parse by DateTime.fromMillisecondsSinceEpoch factory
IsDecimal
Validates that the input is a decimal number. Integers are accepted too, since every integer is a valid double.
IsEgyptianPhone
Validates that the input is an Egyptian mobile number (010/011/012/015 + 8 digits).
IsEmail
checks if the input is a valid email address
IsEmpty
Validates that the input is empty or whitespace-only.
IsEnglishChars
Validates that the input contains only English (A–Z) letters.
IsFacebookUrl
Validates that the input is a Facebook URL (facebook.com or fb.com).
IsHexColor
checks if the input is valid hex color
IsHindiNum
Validates a positive integer in Arabic-Indic digits, with no leading zero.
IsIn
checks if the input is in provided List;
IsInstagramUrl
Validates that the input is an Instagram URL (instagram.com).
IsIpAddress
Validates that the input is an IPv4 address (four dot-separated octets 0–255).
ISKsaPhone
Validates that the input is a Saudi (KSA) mobile number.
IsLtrLanguage
A validation rule that checks whether a language code is left-to-right (LTR).
IsNotIn
checks if the input is NOT in provided List;
IsNumber
checks if the input is a valid integer
IsNumbersOnly
Validates that the input is all digits (one or more, nothing else).
IsOptional
allows you to skip the errors if the input is null
IsPort
checks if the input is a valid port
IsRequired
Validates that the input is not empty after trimming.
IsRTLLanguage
A validation rule that checks whether a language code is right-to-left (RTL).
IsSecureUrl
checks if the input is a secure url
IsUrl
Validates that the input is an http or https URL.
IsYoutubeUrl
Validates that the input is a YouTube URL (youtube.com).
Match
checks if the input is match other string
MaxLength
checks if the input characters length is smaller than the max field
MaxValue
Validates that the parsed numeric input is less than or equal to max.
MinLength
checks if the input characters length is bigger than the min field
MinValue
Validates that the parsed numeric input is greater than or equal to min.
NotContains
checks if input does not contain the provided value;
NotContainsAny
check if the value does not contain any item from the provided list
RegExpRule
allow using a regular expression as validation rule
StartsWith
Validates that the trimmed input starts with pattern.

Functions

containsAny(String v, List<String> list, {bool caseSensitive = false, bool trim = true}) bool
Returns true if v contains any entry from list (case-insensitive by default).
isArabicChars(String input) bool
Returns true if input consists of Arabic letters, whitespace and Arabic-Indic digits (٠-٩).
isArabicNum(String input) bool
Returns true if input is a positive integer in Latin digits with no leading zero.
isBool(Object? input) bool
Returns true if input is a bool, or the trimmed, case-insensitive string 'true' or 'false'.
isDate(String? v) bool
checks if the input is a valid date to parse by Dart DateTime class
isDateAfter(Object? input, DateTime date) bool
Returns true if input (a String or DateTime) is strictly after date.
isDateMills(String v, {bool isUtc = false}) bool
checks if the input is a valid date to parse by DateTime.fromMillisecondsSinceEpoch factory
isDecimal(String? input) bool
Returns true if input parses as a double via double.tryParse (surrounding whitespace is trimmed first).
isEgyptianNumber(String str) bool
Returns true if str is a valid Egyptian mobile number.
isEmail(String? email) bool
checks if the value can be well formatted email address
isEmpty(String? input) bool
trim the string then checks if isEmpty if string is empty it will returns true
isEnglishChars(String input) bool
Returns true if input consists of English letters only.
isFacebookUrlValid(String url) bool
Returns true if url is an http or https Facebook URL.
isHexColor(String? input) bool
can starts with or without# must contains
isHindiNum(String input) bool
Returns true if input is a positive integer in Arabic-Indic digits with no leading zero.
isIn(Object v, List<Object> list) bool
check if string is in List<String>
isInstagramUrlValid(String url) bool
Returns true if url is an http or https Instagram URL.
isInstgramUrlValid(String url) bool
Deprecated misspelling of isInstagramUrlValid; kept so existing callers keep compiling. Will be removed in a future major release.
isIpAddress(Object? input) bool
Returns true if input is a string holding a strict dotted-quad IPv4 address — no leading zeros, signs or surrounding/embedded whitespace.
isKsaPhone(String input) bool
Returns true if input is a valid Saudi mobile number in a supported format.
isNotEmpty(String? string) bool
trim the string then checks if isNotEmpty
isNotIn(Object v, List<Object> list) bool
check if value is NOT in List
isNumber(String? input) bool
Returns true if input is a base-10 integer (surrounding whitespace is trimmed first). Parsing is pinned to radix: 10, so the 0x hex prefix, scientific notation and decimals are all rejected — use isDecimal for fractional values.
isNumbersOnly(String input) bool
Returns true if input is one or more digits and nothing else.
isPort(Object? input) bool
Returns true if input is an integer port in the range 0–65535.
isSecureUrl(Object? input) bool
Returns true if input is a string starting with https:// (case-insensitive).
isUrlValid(String url) bool
Returns true if url is a well-formed http or https URL.
isYoutubeUrLValid(String url) bool
Returns true if url is an http or https YouTube URL.
match(Object? input, Object? other) bool
checks if two Strings are the same
maxValue(Object? value, num max) bool
Returns true if value parses to a number less than or equal to max.
minLength(String? input, int min) bool
Returns true if input, trimmed, is at least min characters long.
minValue(Object? value, num min) bool
Returns true if value parses to a number greater than or equal to min.
notContainsAny(String v, List<String> list) bool
Returns true if v contains none of the entries in list.