Methods for any constants that require user input should always be the same name as the constant key you have specified when adding a product. So, assume you have added
a product with two constants and they both require user input.
So, here the methods should be named 'Param' & 'Key'. Example:
function Param($input) {
}
function Key($input) {
}
Inside these functions is your validation. So, lets say that the value of 'Key' can only be numeric, you might do:
function Key($input) {
return (ctype_digit($input) ? true : false);
}
This uses the ctype function. You might also do:
function Key($input) {
if (is_numeric($input)) {
return true;
} else {
return false;
}
}
Regular expressions can also be used:
function Key($input) {
if (preg_match('/^\d+$/', $input)) {
return true;
} else {
return false;
}
}
Prefix 'guardian_' to constant keys that begin with a number. So, lets say your constant key is '123key', for input validation use the following function name:
function guardian_123key($input) {
xxxx
}
More examples below.