Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add sanitizers which cast to common data types #2

Closed
rimas-kudelis opened this issue Dec 6, 2018 · 5 comments
Closed

Add sanitizers which cast to common data types #2

rimas-kudelis opened this issue Dec 6, 2018 · 5 comments
Labels
enhancement New feature or request

Comments

@rimas-kudelis
Copy link

Basically, implement casting to bool, int, float, string (this would likely just do nothing), and maybe dates to Carbon instances?

@arondeparon
Copy link
Owner

Great idea! 😄 Have you implemented these sanitizers in your own project already? If so, feel free to submit them in a pull-request and I will consider including them in the default sanitizers.

@arondeparon arondeparon added the enhancement New feature or request label Apr 28, 2019
@francoism90
Copy link

@arondeparon I would be interested in casting, however are these filters? I'm happy to make a PR for it. See examples given by Waavi: https://github.com/Waavi/Sanitizer/blob/master/src/Filters/Cast.php

@arondeparon
Copy link
Owner

@francoism90 looks like an interesting solution! :)

I could imagine doing something like this:

protected $sanitizers = [
    'amount' => [
            Cast::class => [
                'to' => Cast::CAST_TYPE_FLOAT,
            ]
        ]
];

@francoism90
Copy link

@arondeparon That looks cool! I'll take a look at your example and try to implement it. :)

@arondeparon
Copy link
Owner

Good luck! You might be able to draw some inspiration from the FilterVars implementation, which takes options as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants