Download the PHP
package dtimofeev/sanitizer without Composer
On this page you can find all versions of the php package
dtimofeev/sanitizer. It is possible to download/install
these versions without Composer. Possible dependencies are resolved
automatically.
FAQ
After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.
Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.
In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories.
In this case some credentials are needed to access such packages.
Please use the auth.json textarea to insert credentials, if a package is coming from a private repository.
You can look here for more information.
Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
To use Composer is sometimes complicated. Especially for beginners.
Composer needs much resources. Sometimes they are not available on a simple webspace.
If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Simple data sanitization library for PHP 7.1+ without any external library dependencies.
Usage
Aliases
Aliases allow for a single definition of commonly used sanitization rules. They can be defined via SS::createAlias(string $name, SanitizerSchema $schema, bool $persistent = true) and used as normal schema rules SS::alias($name) everywhere, no matter the depth. The $persistent parameter indicates if the alias should be preserved after first full validation (single call of Sanitizer::process(...)). They can also be destroyed manually via SS::destroyAlias(string $name).
Because of the schemas nature these are also more memory efficient than defining a separate schemas.
Example:
Detailed supported methods
SS::boolean()
method
params
description
optional
?bool $default
Sets a default boolean in case a value is not provided for validation.
SS::integer()
method
params
description
optional
?int $default
Sets a default integer in case a value is not provided for validation.
min
int $value
Checks if the value is above or equal to the one provided in parameter.
max
int $value
Checks if the value is below or equal to the one provided in parameter.
between
int $min, int $max
Checks if the value is between minimum and maximum provided in params.
equals
int $expected
Checks if the value is equal to the one provided in parameter.
not
int $unexpected
Checks if the value is not equal to the one provided in parameter.
oneOf
int[] $values
Checks if the value is one of the array provided in parameter.
notOneOf
int[] $values
Checks if the value is not one of the array provided in parameter.
SS::string()
method
params
description
optional
?string $default
Sets a default string in case a value is not provided for validation.
trim
bool $left = true, bool $right = true
Trims spaces from the start(in case $left = true) and from the end(in case $right = true). Note: at least one of both parameters have to be set to true.
length
bool $length, string $charset = 'UTF-8'
Checks if the value length is exactly the same as the one provided in $length parameter.
min
bool $length, string $charset = 'UTF-8'
Checks if the value length is greater or equal to the one provided in $length parameter.
max
bool $length, string $charset = 'UTF-8'
Checks if the value length is smaller or equal to the one provided in $length parameter.
oneOf
string[] $values, bool $strict = true
Checks if the value is one of the array provided in parameter.
notOneOf
string[] $values, bool $strict = true
Checks if the value is not one of the array provided in parameter.
email
-
Checks if the value is a valid email address.
ip
bool $v4 = true, bool $v6 = false
Checks if the value is a valid IP address. Flags in parameters indicate if v4/v6 should be considered valid.
url
bool $httpsOnly = false
Checks if the value is a valid URL. $httpsOnly flags indicates in only https:// URLs should be considered valid.
regex
string $pattern, string $name = null
Checks if the value matches a specific regular expression pattern. Parameter $name is used for naming the pattern and will be displayed in error message instead of the whole pattern.
alpha
bool $dash = false, bool $space = false
Checks if the value contains only characters from A to Z, lower or uppercase. Parameter $dash indicates if - and _ characters should also be allowed. Parameter $space indicates if spaces should also be allowed.
alphaNum
bool $dash = false, bool $space = false
Checks if the value contains only characters from A to Z, lower or uppercase + numbers. Parameter $dash indicates if - and _ characters should also be allowed. Parameter $space indicates if spaces should also be allowed.
SS::date()
method
params
description
optional
?string $default
Sets a default date in case a value is not provided for validation. Value should be in the same format as instantiated date.
before
string $date
Checks if validated date is before the one provided in parameter.
after
string $date
Checks if validated date is after the one provided in parameter.
SS::arr()
method
params
description
optional
?array $default
Sets a default array in case a value is not provided for validation.
scalar
-
Checks if all values of the validated array are scalar.
unique
-
Checks if all values of the validated array are unique.
each
SanitizerSchema $schema
Checks if each of the values of the validated array satisfy the specified $schema
schema
array $schema
Validates every key => value based on provided schema.
min
int $length
Validates if array has $min minimum length.
max
int $length
Validates if array has $max maximum length.
SS::decimal()
method
params
description
optional
?string/int/float $default
Sets a default string/int/float in case a value is not provided for validation.
min
string/int/float $value
Checks if the value is above or equal to the one provided in parameter.
max
string/int/float $value
Checks if the value is below or equal to the one provided in parameter.
Custom error messages
Error messages are defined inside a static map SanitizerException::$messages and can be easily redefined. This can be used for multilingual messages for example.
Composer command for our command line client (download client)This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free.Standard composer command
The package dtimofeev/sanitizer contains the following files
Loading the files please wait ....
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.