Description
This library provides a service that can be used to filter object values based on annotations
DMS Filter alternatives and similar libraries
Based on the "Filtering and Validation" category.
Alternatively, view DMS Filter alternatives based on common mentions on social networks and blogs.
-
ISO-codes
PHP library - Validators for standards from ISO, International Finance, Public Administrations, GS1, Manufacturing Industry, Phone numbers & Zipcodes for many countries -
PHP validate
Lightweight and feature-rich PHP validation and filtering library. Support scene grouping, pre-filtering, array checking, custom validators, custom messages. 轻量且功能丰富的PHP验证、过滤库。支持场景分组,前置过滤,数组检查,自定义验证器,自定义消息。 -
Linio Input
Abstracts HTTP request input handling, providing an easy interface for data hydration and validation -
Cake Validation
[READ-ONLY] Validation library from CakePHP. This repo is a split of the main code that can be found in https://github.com/cakephp/cakephp -
EU VAT Number Validator
:moneybag: A simple and clean PHP library that validates EU VAT registration numbers against the central ec.europa.eu database (using the official europa API) :eu: -
CSV Blueprint
Strict and automated line-by-line CSV validation tool based on customizable Yaml schemas -
Distributed locks with Redis and ReactPHP
:lock: Asynchronous distributed locks with Redis and ReactPHP
InfluxDB - Purpose built for real-time analytics at any scale.
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of DMS Filter or a related project?
README
DMS Filter Component
This library provides a service that can be used to filter object values based on annotations
Install
Use composer to add DMS\Filter to your app
composer require dms/dms-filter
Usage
Your Entity:
<?php
namespace App\Entity;
//Import Annotations
use DMS\Filter\Rules as Filter;
class User
{
/**
* @Filter\StripTags()
* @Filter\Trim()
* @Filter\StripNewlines()
*
* @var string
*/
public $name;
/**
* @Filter\StripTags()
* @Filter\Trim()
* @Filter\StripNewlines()
*
* @var string
*/
public $email;
}
?>
Filtering:
<?php
//Get Doctrine Reader
$reader = new Annotations\AnnotationReader();
$reader->setEnableParsePhpImports(true);
//Load AnnotationLoader
$loader = new Mapping\Loader\AnnotationLoader($reader);
$this->loader = $loader;
//Get a MetadataFactory
$metadataFactory = new Mapping\ClassMetadataFactory($loader);
//Get a Filter
$filter = new DMS\Filter\Filter($metadataFactory);
//Get your Entity
$user = new App\Entity\User();
$user->name = "My <b>name</b>";
$user->email = " [email protected]";
//Filter you entity
$filter->filter($user);
echo $user->name; //"My name"
echo $user->email; //"[email protected]"
?>
Full example: https://gist.github.com/1098352
Dependencies
This package relies on these external libraries:
- Doctrine Annotations
Contributing
Feel free to send pull requests, just follow these guides:
- Fork
- Code
- Test
- Just create FilterTestCase and run
phpunit
- Just create FilterTestCase and run
- Submit PR
Credits
This library is inspired by the Symfony 2 Validator component and is meant to work alongside it.
Symfony 2 Validator: https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Validator
*Note that all licence references and agreements mentioned in the DMS Filter README section above
are relevant to that project's source code only.