Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jawira/sanitizer
Sanitize your objects with attributes
https://github.com/jawira/sanitizer
attributes php sanitization
Last synced: 4 months ago
JSON representation
Sanitize your objects with attributes
- Host: GitHub
- URL: https://github.com/jawira/sanitizer
- Owner: jawira
- License: mit
- Created: 2023-06-30T07:06:43.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-08-20T18:16:55.000Z (6 months ago)
- Last Synced: 2024-09-30T14:11:02.308Z (4 months ago)
- Topics: attributes, php, sanitization
- Language: PHP
- Homepage: https://jawira.github.io/sanitizer/
- Size: 2.82 MB
- Stars: 8
- Watchers: 2
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# 😷 jawira/sanitizer
**Sanitize your objects with attributes.**
> [!CAUTION]
> **v1.1.0 BC break**
> Due to a mistake, a new namespace must be used with attributes:
> ```php
> use Jawira\Sanitizer\Cleaners as Filter;
> ```[![Latest Stable Version](http://poser.pugx.org/jawira/sanitizer/v)](https://packagist.org/packages/jawira/sanitizer)
[![Total Downloads](http://poser.pugx.org/jawira/sanitizer/downloads)](https://packagist.org/packages/jawira/sanitizer)
[![PHP Version Require](http://poser.pugx.org/jawira/sanitizer/require/php)](https://packagist.org/packages/jawira/sanitizer)
[![License](http://poser.pugx.org/jawira/sanitizer/license)](https://packagist.org/packages/jawira/sanitizer)## Usage
Add sanitizer attributes to your class:
```php
use Jawira\Sanitizer\Cleaners as Filter;class User {
#[Filter\Trim]
#[Filter\Title]
public string $name;
}
```Call `Sanitizer::sanitize` method to apply sanitizers:
```php
use Jawira\Sanitizer\Sanitizer;$user = new User();
$user->name = ' BOB ';$sanitizer = new Sanitizer();
$sanitizer->sanitize($user);echo $user->name; // 'Bob'
```Interface `SanitizerInterface` is also available.
## Documentation
## Install
```console
composer require jawira/sanitizer
```## Security
> **Warning**
> Sanitization is not a replacement for a proper data validation mechanism and
> database constraints.## License
This library is licensed under the [MIT license](LICENSE.md).
***
## Packages from jawira
-
jawira/doctrine-diagram-bundle
- Symfony Bundle to generate database diagrams.
-
jawira/case-converter
- Convert strings between 13 naming conventions: Snake case, Camel case,
Pascal case, Kebab case, Ada case, Train case, Cobol case, Macro case,
Upper case, Lower case, Sentence case, Title case and Dot notation. -
jawira/emoji-catalog
- Get access to +3000 emojis as class constants.
- more...