SafeParam
class SafeParam
Class representing a client input parameter
Provides a consistent interface for sanitizing and validating input values A value is considered null if it is an empty string or the string "null"
Constants
| TYPE_RAW |
A raw value that does no sanitizing or validating |
| TYPE_BOOL |
A boolean value, see FILTER_VALIDATE_BOOLEAN |
| TYPE_INT |
An integer value, see FILTER_VALIDATE_INT |
| private TYPE_INT_FIRST |
|
| TYPE_INT32 |
|
| TYPE_INT16 |
|
| TYPE_INT8 |
|
| TYPE_UINT |
An integer value, see FILTER_VALIDATE_UINT |
| TYPE_UINT32 |
|
| TYPE_UINT16 |
|
| TYPE_UINT8 |
|
| private TYPE_INT_LAST |
|
| TYPE_FLOAT |
A float value, see FILTER_VALIDATE_FLOAT |
| TYPE_RANDSTR |
A value matching the format randomly generated by Andromeda |
| TYPE_ALPHANUM |
An alphanumeric (and -_.) value |
| TYPE_NAME |
A value representing a name, allows alphanumerics and -_'(). and space, max length 255 |
| TYPE_EMAIL |
An email address value, see FILTER_VALIDATE_EMAIL |
| TYPE_FSNAME |
A file name value, see details FILTER_FLAG_STRIP_LOW, max length 255, checks for directory traversal, forbids invalid characters \/?*:;} |
| TYPE_FSPATH |
A filesystem path, see details FILTER_FLAG_STRIP_LOW, max length 65535, forbids invalid characters ?*:;} |
| TYPE_HOSTNAME |
A value containing a hostname, see FILTER_FLAG_STRIP_LOW, FILTER_VALIDATE_DOMAIN and FILTER_FLAG_HOSTNAME |
| TYPE_URL |
A value containing a full URL, see FILTER_VALIDATE_URL |
| TYPE_TEXT |
A string value with a max length of 65535, HTML-escapes special characters, see FILTER_SANITIZE_SPECIAL_CHARS |
| TYPE_OBJECT |
A value that itself is a collection of SafeParams (an associative array) |
| TYPE_ARRAY |
can be combined with any type to indicate an array of that type |
| TYPE_STRINGS |
|
Properties
| private | $key | ||
| private | $value |
Methods
Returns the string representing the given param type for printing
Construct a new SafeParam with the given key and value
Returns the key name of the SafeParam
Returns the raw value of the SafeParam - caution!
Returns a function that checks the max length of the value, for use with GetValue
Gets the value of the parameter, doing filtering/validation, and JSON decoding for objects/arrays
Details
at line 139
static string
GetTypeString(int $type)
Returns the string representing the given param type for printing
at line 153
__construct(string $key, $value)
Construct a new SafeParam with the given key and value
at line 164
string
GetKey()
Returns the key name of the SafeParam
at line 167
GetRawValue()
Returns the raw value of the SafeParam - caution!
at line 170
static callable
MaxLength(int $len)
Returns a function that checks the max length of the value, for use with GetValue
at line 186
null|mixed|SafeParam[]|SafeParams
GetValue(int $type, array|null $values = null, callable|null $valfunc = null)
Gets the value of the parameter, doing filtering/validation, and JSON decoding for objects/arrays
If the parameter is an object type, a SafeParams object will be returned If the parameter is an array type, returns an array of SafeParams