Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Automatic validation #240
The entire entity validation logic should be reimplemented. I believe it's wrong how it works now because it makes almost impossible to use it at all. See the following scenario.
This request will always fail even it is just a GET request and
Having a single HandleError method is a very bad idea in my opinion because when you end up in HandleError method your context is lost. You don't know the action where the error occurred and how you're supposed to handle it. You just end up with an error object you have to deal with but you don't know how. In the wild that's not always the case. Validation can be complex and might have a lot of logic behind and it needs to be very flexible. Magic kills flexibility. This might make sense If we would have single action controllers or single verb per action. But as longs as you have multiple verbs per action you gonna have a really bad day. :sad:
A better approach would be to remove any automatic validation and let the user handle it. I mean the context could have a method
@vcraescu Thanks for reporting an issue.
The scenario you have described, its seems you're having using same controller action for
Begin said that, I'm sorry, you had to spend time much around this one. I'm disappointed since one of the goal of
Thanks for bringing up, I would surely make validation flow flexible and extensible for every possible scenario.
One of the goal of
Let's take a spin for what aah currently provides -
So from the context of validation, what would be error object values: reason as
Let's take a spin for what aah currently missing -
What are the possible solutions we could go for -
Solution 3: (this is similar as your proposed solution)
PS: Solution 3 have possibility of removing validation library from aah. It means aah user could have their choice validation library and performing validation at controller action.
@jeevatkm Yes, I'm using multiple verbs for an action. The app we're building right now It's just a prototype and we just render ol' school html. No REST, just plain html.
I'm not big fan of having a different method for validation because inside Action method you might have some logic to render the current action. Things which you will put into aah.Data object and pass it to the view. You usually do that before you actually validate the object because it is needed even the object is valid or not. If you're being moved to a different method to handle the error basically you will have to duplicate that logic there. Example:
If the object is not valid, inside HandleErrorEdit method I will have to do this part again before I add the errors to aah.Data object: