Sanitizing user input is a critical part of software development. Trusting or neglecting to sanitize user input could lead to unauthorized access to the content of your application, mainly user data, or even the server your application is hosted on.
You can add your own filters into the PHP Configuration file.
.env
# define your own service providerPROVIDER_COOKIES=\Zemit\Provider\Filter\ServiceProvider
./app/config/config.php
'filters'=> [Filter::FILTER_MD5 =>Filters\Md5::class,Filter::FILTER_JSON =>Filters\Json::class,Filter::FILTER_IPV4 =>Filters\IPv4::class,Filter::FILTER_IPV6 =>Filters\IPv6::class,// You can add your own custom filters'my-custom-filter'=>App\Filters\Custom::class,],
// examples using custom filters$this->filter->sanitize($md5,Filter::FILTER_MD5);$this->filter->sanitize($json,Filter::FILTER_JSON);$this->filter->sanitize($ipv4,Filter::FILTER_IPV4);$this->filter->sanitize($ipv5,Filter::FILTER_IPV6);// using your own custom filter$this->filter->sanitize($custom,'my-custom-filter');// if the class is aware of injections$filter =$this->filter;// if the container is present$filter =$this->di->get('filter');// from outside$filter =Di::getDefault()->get('filter');