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

Input Validation #519

Conversation

DeveloperMarius
Copy link
Contributor

Hey,

This pull requests contains a validation for InputItems and a requireParameters for the InputHandler. The developer can enable and disable the throwing of errors for the Input validation in Router::setValidationErrors. I maby would change this with the time to $input_errors and work more with errors in the InputHandler and add this to InputHandler::exists() that users who work a lot with the ExceptionHandler and error catching there have it easyer in their controllers.

The requireParameters function can look like the following:

SimpleRouter::request()->input()->requireParameters(array(
    'password',
    'new_password' => function($value){
        return $value->validator()->require()->minLength(6)->isString()->valid();
    }
));

Maby I also would change the source and content for the error messages (maby using a config?). What do you think @skipperbent?
What do you think in general of my approach? Yes using the check() method this is a bit complicated, but it's also simpler.

~ Marius

@DeveloperMarius
Copy link
Contributor Author

I added the parse function into the InputItem.
I only parse floats and integer when they are numeric. I thought that is the best.
I only parse booleans when they are: "true", "false", "1", 1, "0" or 0. I'm not sure if I should parse all values to booleans, because they can be parsed, but they really have nearly nothing to do with an boolean.

~ Marius

@DeveloperMarius
Copy link
Contributor Author

Avoid using " as they're more expensive than ' due to the fact that they parse parameters, for example:

Yes I know, sry. I think it's a bit too late^^
I will change it and remove the validation before I parse the value.

@skipperbent
Copy link
Owner

Avoid using " as they're more expensive than ' due to the fact that they parse parameters, for example:

Yes I know, sry. I think it's a bit too late^^
I will change it and remove the validation before I parse the value.

Don't worry it's not going to dramatically decrease performance. But every little thing counts, that's what makes coding interesting. V4.3 is released btw.. hopefully I didn't introduce too many new bugs. Fingers crossed :)

@DeveloperMarius
Copy link
Contributor Author

Yes, I also like ' more then ", but I wrote python today and used them...
Yes I saw the release, perfect 👍🏻. We will see, but I think the unit tests helped a lot.

@DeveloperMarius
Copy link
Contributor Author

DeveloperMarius commented Apr 26, 2021

Hey @skipperbent,
are you all right? Haven't heard from you a long time^^
Would love to get feedback from you. I know it's a lot of code and you need time to look threw it, but it would help a lot and you can setup the v5 branch.
Looking forward to your answer!
The new Inputhandler pull would be the most important for me.

~ Marius

@skipperbent
Copy link
Owner

Hi Marius.

I've been busy with a new exciting project that takes much of my time lately. Hope you're doing well - I will look into your code later today I promise 👍

/ Simon

@DeveloperMarius
Copy link
Contributor Author

Okay, thank you!
Yes, now I see. You are updating your pecee-pixie repro.
Looking forward to your comments^^
~ Marius

@skipperbent
Copy link
Owner

Okay, thank you!
Yes, now I see. You are updating your pecee-pixie repro.
Looking forward to your comments^^
~ Marius

I'm working on a Umbraco clone for PHP. It takes a lot of time, it's a huge project. I will release it on GitHub as soon as it has all the features required for launch. Still need multi-language, auto installer and a working default-theme.

2021-04-28_10-24-10

2021-04-28_10-26-26

2021-04-28_10-27-29

@DeveloperMarius
Copy link
Contributor Author

I created my own CMS for my customers and I know how mutch work something like this coasts! This looks nice and I'm looking forward to see more of it^^

@DeveloperMarius
Copy link
Contributor Author

Maybe I can later add some features like 2-FA app and 2-FA Keys. Added this in my own and I have to say that this makes it way more saver^^

@skipperbent
Copy link
Owner

skipperbent commented Apr 28, 2021

Yes, it's so much work. But I'm getting there... The system will allow developers to create their own classes, use dependencies from composer and design their projects in the fashion of their liking.

Each node has a "template" which is just a class that inherits a special interface. It can be defined on the node-type what template can be chosen on that given type. Each node-type has defined what data-types are available like "text-field", "richtext editor" etc. Data-types are editor classes that can be rendered when editing a page. Same goes for media and members.

If you want pages you just call the alias of the nodes-you want, for instance ModelPage::filterAlias('textpage')->all() or maybe you want some child nodes $this->node->getChildren()->first().

$slider = ModelPage::filterType('slider')->first();

foreach($slider->getChildrenOfType('slide')->all() as $slide) {
     $title = $slide->getTitle();
     $text = $slide->getData('text');
     $image = $slide->getData('image');
}

Data elements are defined by the data-types, which is something a developer choses.

I understand if it sounds confusing for someone that haven't used Umbraco, but when everything is nodes it makes it really simple to working with the content.

2FA would be nice, I'm looking forward to sharing the project with you 😄

@DeveloperMarius
Copy link
Contributor Author

Hi Marius.

I've been busy with a new exciting project that takes much of my time lately. Hope you're doing well - I will look into your code later today I promise 👍

/ Simon

Do you think you can do it today or should I expect your feedback next weekend? I just need basic feedback of my PRs. I think my #515 is ready, but the input validation and input handler needs some feedback if you want more functionality or some changes. I will delete my #511 later today, because you included the IP whitelist already. Or should I try to include the device whitelist your way?

~ Marius

@DeveloperMarius
Copy link
Contributor Author

Hi Marius.

I've been busy with a new exciting project that takes much of my time lately. Hope you're doing well - I will look into your code later today I promise 👍

/ Simon

Hey @skipperbent,
I know you have been busy and I know that I was too, but can you just tell me that you will do it in like 2 weeks or something like that? It have been 1 month and I really like to use my PRs in my own projects. Please take a view hours in your schedule to review my PRs. I really want to enhance this project because I love this router, but I need your feedback for this.

~ Marius

@guiiamorim
Copy link

Hello! Thanks for the great package.

There's any plans to include this feature any time soon? I'd love to have this on a project I'm working on right now.

@DeveloperMarius DeveloperMarius mentioned this pull request Feb 1, 2022
8 tasks
@DeveloperMarius
Copy link
Contributor Author

Hello,

I will close this PR, because we are searching for a better alternative in PR #607.

~ Marius

@DeveloperMarius DeveloperMarius deleted the input-validation branch November 15, 2022 09:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants