Coder Social home page Coder Social logo

sanitizer's Introduction

๐Ÿ˜ท 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:

use Jawira\Sanitizer\Cleaners as Filter;

Latest Stable Version Total Downloads PHP Version Require License

Usage

Add sanitizer attributes to your class:

use Jawira\Sanitizer\Cleaners as Filter;

class User {
    #[Filter\Trim]
    #[Filter\Title]
    public string $name;
}

Call Sanitizer::sanitize method to apply sanitizers:

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

https://jawira.github.io/sanitizer/

Install

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.


Packages from jawira

jawira/doctrine-diagram-bundle GitHub stars
Symfony Bundle to generate database diagrams.
jawira/case-converter GitHub stars
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 GitHub stars
Get access to +3000 emojis as class constants.
more...

sanitizer's People

Contributors

jawira avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

sanitizer's Issues

Follow sanitizer

Follow sanitizer does not modify the value, instead it tells Sanitizer::sanitize to do "follow" or do recursive search.

Add groups

Sanitizers could have groups, then only sanitizer from selected group will be executed.
For example group "create", "update", "user", "admin", ...

Each sanitizer

Each sanitizer applies a sanitizer to each element of an array.

Cast

Create sanitizer to cast values.

Maybe single sanitizer to cast all types, or one sanitizer per type.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.