The usage is of cource a little diffrent when you are validating forms made in CT, or backend (manully coded). If you are going to do an manuallt implementation then take a look at method list and draw your own conclutions.
When you are going to create a validatation for a input field created with CT form builder you will have two fields "Method" and "Value". Method is the method name that exists in "\form\valid" framework and value is the selected methods arguments. This means that you only need to take a look at the method list bellow (You can skip the Examples and Start instance, those are for manual usage) copy the method name and if the method has multiple arguments then seperate them as a comma sperated string.
Copy the method name "length" and paste it in the "Method" field in CT.
Complete method list
-
@example 1: \form\valid::_val("Lorem ipsum dolor")->length(1);
True becouse the length is more than 1
-
@example 2: \form\valid::_val("Lorem ipsum dolor")->length(1, 200);
True becouse the length is 17
-
@example 3: \form\valid::_val("+46709687050")->phone();
True becouse is phone number
-
@example 4: \form\valid::_val("daniel@creativearmy.se")->allOf(["email", "length" => [1, 120]]);
True becouse value mathes all the validations
-
@param ALL $value the input value
@return inst(self)
static _val($value)
@return instance (form\luhnValidation)
luhn()
Set field required (same as @length(1));
@return bool
required()
socialNumber()
personnummer()
orgNumber()
creditcard()
vatNumber()
Loosely check if is email. By loosley I mean it will not check if valid DNS. You can check this manually with the method @dns but in most cases this will not be necessary.
@return bool
email()
@param string $match keyword to match agains
@param int|null $pos match start positon if you want
@return bool
findInString(string $match, ?int $pos = NULL)
Alternative "Find in string" @findInString()
strpos(string $match, ?int $pos = NULL)
phone()
@param int $a start length
@param int|null $b end length
@return bool
zip(int $a, int $b = NULL)
number()
positive()
negative()
min(float $i)
Value is minimum float|int value (Same as "@min()" but can be used to add another error message)
@return bool
minAlt(float $i)
max(float $i)
float()
int()
@param int $a start length
@param int|null $b end length
@return bool
length(int $a, int $b = NULL)
isRequired()
@param string $key HTTP Post KEY
@param int $a start length
@param int|null $b end length
@return bool
hasLength(string $key, int $a, int $b = NULL)
@param int $a length
@return bool
equalLength(int $a)
equal($str)
notEqual($str)
string()
pregMatch($matchStr)
AtoZ()
lowerAtoZ()
upperAtoZ()
hex()
array()
object()
bool()
boolVal()
@param int|float|string|date $a 10, a, 1988-08-01
@param int|float|string|date $b 20, z, 1988-08-20
@return bool
between($a, $b)
@param string $format validate after this date format (default Y-m-d)
@return bool|inst(dateTime)
date($format = "Y-m-d")
@param string $format validate after this date format (default Y-m-d H:i)
@return bool|inst(dateTime)
dateTime($format = "Y-m-d H:i")
@param string $format validate after this date format (default Y-m-d H:i)
@return bool|inst(dateTime)
time($format = "H:i")
@param string $format validate after this date format (default Y-m-d H:i)
@return bool / array(T1, T2); T1 = start and T2 = end
dateRange($format = "Y-m-d H:i")
@param int $a 18 == user should be atleast 18 years old
@return [type] [description]
age(int $a)
@param boolean $flag stricter = true
@return bool
domain($flag = true)
url()
dns()
@param int $type (DNS_A, DNS_CNAME, DNS_HINFO, DNS_CAA, DNS_MX, DNS_NS, DNS_PTR, DNS_SOA, DNS_TXT, DNS_AAAA, DNS_SRV, DNS_NAPTR, DNS_A6, DNS_ALL or DNS_ANY)
@param string $value IPv4, IPv6, String, txt
@return false/array
matchDNS(int $type, string $value)
@param [type] $arr [description]
@return [type] [description]
oneOf(array $arr)
@param [type] $arr [description]
@return [type] [description]
allOf(array $arr)