Validator Sub-Module Documentation⚓︎
Overview⚓︎
The Validator sub-library is a collection of functions designed to check and validate strings.
It provides a range of checks for various characteristics.
These functions are useful for verifying the correctness and suitability of strings in various contexts.
Notice
There could be boolean outputs that be grouped and be separated by a single line for better appearance without an additional print between.
Functions⚓︎
IsNumeric⚓︎
Purpose⚓︎
This function checks if the given string represents a numeric value.
It returns true
if the string is a numeric value, false
otherwise.
This function considers a numeric value as a string that can be converted to a number type, such as integer, float, or double.
Syntax⚓︎
IsNumeric(Str: string): boolean
Parameters⚓︎
Str: string
The input string to check.
Returns⚓︎
- boolean
true
if the input string represents a numeric value,false
otherwise.
Examples⚓︎
1 2 3 4 5 6 7 8 9 |
|
1 2 3 4 5 6 7 8 9 |
|
IsInteger⚓︎
Purpose⚓︎
This function checks if the given string represents an integer value.
Syntax⚓︎
IsInteger(Str: string): boolean
Parameters⚓︎
Str: string
The string to be checked.
Returns⚓︎
- boolean
A boolean value indicating whether the given string represents an integer value or not.
If the string represents an integer value, the function returnstrue
, otherwise it returnsfalse
.
Examples⚓︎
1 2 3 4 5 6 7 |
|
1 2 3 4 5 6 7 |
|
IsAlpha⚓︎
Purpose⚓︎
Checks if a string consists only of alphabetical characters and spaces.
It returns a boolean value indicating whether the string is made up of only alphabetical characters and spaces or not.
Syntax⚓︎
IsAlpha(Str: string): boolean
Parameters⚓︎
Str: string
The string to be checked.
Returns⚓︎
- boolean
A boolean value indicating whether the string is made up of only alphabetical characters and spaces or not.
Examples⚓︎
1 2 3 4 5 6 7 8 9 |
|
1 2 3 4 5 6 7 8 9 |
|
IsAlphaNum⚓︎
Purpose⚓︎
A function that checks if a given string is alphanumeric or not.
An alphanumeric string is a string that consists of only letters (a-z, A-Z) and digits (0-9) along with spaces if there any.
Syntax⚓︎
IsAlphaNum(Str: string): boolean
Parameters⚓︎
Str: string
The string to be checked.
Returns⚓︎
- boolean
A boolean value oftrue
if the given string is alphanumeric andfalse
if it is not.
Examples⚓︎
1 2 3 4 5 6 7 8 |
|
1 2 3 4 5 6 7 8 |
|
IsBlank⚓︎
Purpose⚓︎
Checks if the given string is blank (only consists of space characters1) or empty.
Syntax⚓︎
IsBlank(Str: string): boolean
Parameters⚓︎
Str: string
A string to check if it is blank or not.
Returns⚓︎
- boolean
A boolean value indicating whether the given string is blank or not.
A string is considered blank if it consists only of whitespace characters or is empty.
Examples⚓︎
1 2 3 4 5 6 |
|
1 2 3 4 5 6 |
|
IsUpper⚓︎
Purpose⚓︎
Checks if the provided string is uppercase.
It returns a boolean value indicating if the string is uppercase or not.
Syntax⚓︎
IsUpper(Str: string): boolean
Parameters⚓︎
Str: string
A string to check if it is upper-case or not.
Returns⚓︎
- boolean
true
if the input string does not contain any lower-case characters, otherwise, the returned value isfalse
.
Examples⚓︎
1 2 3 4 5 6 7 |
|
1 2 3 4 5 6 7 |
|
IsLower⚓︎
Purpose⚓︎
Checks if the provided string is lowercase.
It returns a boolean value indicating if the string is lowercase or not.
Syntax⚓︎
IsLower(Str: string): boolean
Parameters⚓︎
Str: string
A string value to be checked.
Returns⚓︎
- boolean
A boolean value indicating if the provided string is lower-case or not.
Examples⚓︎
1 2 3 4 5 6 7 |
|
1 2 3 4 5 6 7 |
|
IsTagged⚓︎
Purpose⚓︎
This function checks whether a given string is possibly tagged or not.
A string is considered tagged if it is only contains hashtags "#" if FullMatch is true
or nil
, also, considered tagged if it contains three or more hashtags in sequence "###"
while FullMatch is false
.
Syntax⚓︎
IsTagged(Str: string, FullMatch: boolean?): boolean
Parameters⚓︎
Str: string
The string to check.FullMatch: boolean
Optional
A boolean value indicating whether the given string should be entirely tagged or just be a part of it. The default value istrue
.
Returns⚓︎
- boolean
A boolean value indicating whether the given string is possibly tagged or not.
Examples⚓︎
1 2 3 4 5 6 7 |
|
1 2 3 4 5 6 7 |
|
IsASCII⚓︎
Purpose⚓︎
Checks if a given string is an ASCII string or not.
An ASCII string is a string that only contains ASCII characters, which are a set of 128 characters (0-127) defined in the ASCII standard.
Syntax⚓︎
IsASCII(Str: string): boolean
Parameters⚓︎
Str: string
The string to check.
Returns⚓︎
- boolean
A boolean value indicating whether the input string consists only of ASCII characters (code points 0-127).
Examples⚓︎
1 2 3 4 |
|
1 2 3 4 |
|
IsHexColor⚓︎
Purpose⚓︎
Checks if a given string is a valid hexadecimal color representation.
Syntax⚓︎
IsHexColor(Str: string, EnforceHash: boolean?): boolean
Parameters⚓︎
Str: string
The string to check.EnforceHash: boolea
Optional
A boolean value which specifies if the hexadecimal color representation should start with the hashtag symbol#
or not.
Returns⚓︎
- boolean
A boolean value indicating whether the string is a valid hexadecimal color representation or not.
If theEnforceHash
argument istrue
, the function requires the#
symbol to be present in the color representation.
IfEnforceHash
isfalse
ornil
, the presence of the#
symbol is optional.
Examples⚓︎
1 2 3 4 5 6 7 8 |
|
1 2 3 4 5 6 7 8 |
|
IsPalindrome⚓︎
Purpose⚓︎
Used to determine if a given string is a palindrome.
A palindrome is a word, phrase, number, or other sequence of characters that reads the same backward as forward.
Syntax⚓︎
IsPalindrome(Str: string, CaseSensitive: boolean?): boolean
Parameters⚓︎
Str: string
The input string to check.CaseSensitive: boolean
Optional
A boolean value indicating whether the check should be case-sensitive or not.
The default value isfalse
.
Returns⚓︎
- boolean
A boolean value indicating whether the string is a palindrome or not.
Examples⚓︎
1 2 3 4 5 6 7 |
|
1 2 3 4 5 6 7 |
|
IsTitile⚓︎
Purpose⚓︎
Used to determine if a given string is in title case format.
Syntax⚓︎
IsTitle(Str: string, Strict: boolean?): boolean
Parameters⚓︎
Str: string
A string to check if it is a title.Strict: boolean
Optional
A boolean value that indicating whether the function should enforce strict adherence to the title format.
If Strict is not provided, it is set tofalse
by default.
Returns⚓︎
- boolean
A boolean value indicating whether the input string is in title case format.
Examples⚓︎
1 2 3 4 5 6 7 8 9 |
|
1 2 3 4 5 6 7 8 9 |
|
Starts⚓︎
Purpose⚓︎
Checks whether a string starts with any of the specified prefixe(s).
Syntax⚓︎
Starts(Str: string, Prefixes: (string | {string})): boolean
Parameters⚓︎
Str: string
The string to check.Prefixes: (string | table)
A single string or an array of strings representing the prefixes to check for.
Returns⚓︎
- boolean
A boolean value indicating whether the string starts with any of the specified prefixe(s).
Examples⚓︎
1 2 3 4 5 6 7 8 |
|
1 2 3 |
|
Ends⚓︎
Purpose⚓︎
Determines whether a string ends with one of the specified suffixes.
It returns true
if the string ends with any of the suffixes, and false
otherwise.
Syntax⚓︎
Ends(Str: string, Suffixes: (string | {string})): boolean
Parameters⚓︎
Str: string
The string to be checked.Suffixes: (string | table)
The suffix string or an array of suffixes to be checked.
Returns⚓︎
- boolean
A boolean value indicating whether the string ends with any of the specified suffixes.
Examples⚓︎
1 2 3 4 5 6 7 8 9 10 11 |
|
1 2 3 4 |
|
Contains⚓︎
Purpose⚓︎
Returns a boolean value indicating whether the given string contains any of the specified SubStrings
.
If the SubStrings
parameter is a single string, then the function will return true
if the substring is found within the Str
.
If SubStrings
is an array of strings, then the function will return true
if any of the strings in the table are found within the given Str
.
Syntax⚓︎
Contains(Str: string, SubStrings: (string | {string})): boolean
Parameters⚓︎
Str: string
The string to search in.SubStrings: (string | table)
The substring or substrings to search for. Can be a single string or an array of strings.
Returns⚓︎
- boolean
A boolean indicating whether the string contains the given substring or any of substrings. - string
The substring that was found, if any or an empty string. - number
The starting index of the substring in the string. - number
The ending index of the substring in the string.
Examples⚓︎
1 2 3 4 5 6 7 8 |
|
1 2 3 |
|
Notice
If there isn't any found substring in the given string, the function would simply return an empty string for the second tuple value (a.k.a. the found substring), along with 0
for the rest of the tuple (start and end indexes).
IsValidUsername⚓︎
Purpose⚓︎
Checks whether or not the given string is a valid username for Roblox platform by doing some top-layer validations.
It checks that the username meets certain criteria such as length, characters allowed, and appropriateness.
Syntax⚓︎
IsValidUsername(Str: string): boolean
Parameters⚓︎
Str: string
A string to check if it is a valid username.
Returns⚓︎
- boolean
A boolean value indicating whether the input string is actually a valid username by returningtrue
or not by returningfalse
. - string
A string value that provides feedback on why the validation failed if the result isfalse
.
This would be an empty string if the username validation has succeeded.
Examples⚓︎
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
|
1 2 3 4 5 6 7 |
|
Warning
Please note that this function only provides a basic validation for input strings and does not check the input text for inappropriate words or filter it.
It is important to consider additional filtering for the input text, especially if it will be visible to others.
PasswordValidate⚓︎
Purpose⚓︎
A basic password validation function that returns if the password is valid, its expected strength score, and a feedback string if it was not valid.
Syntax⚓︎
PasswordValidate(Password: string, EnforceStandardRequirements: boolean?): boolean
Parameters⚓︎
Password: string
A password string to check for its validity and strength.EnforceStandardRequirements: boolean
Optional
A boolean that determines whether the standard requirements for a password be enforced on the given string or not2.
Default:false
.
Returns⚓︎
- boolean
A boolean value indicating whether the input string is actually a valid username by returningtrue
or not by returningfalse
. - number
An expected strength for the given string its range is between 0-100. - string
If the sthring given is not valide, a feedback string represents the reason of why the password is not valid is returned; Otherwise, anil
value is returned.
Examples⚓︎
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
|
1 2 3 4 5 6 7 8 9 10 |
|