Welcome Guest, Not a member yet? Register   Sign In
Validation callback
#2

(This post was last modified: 11-19-2017, 07:15 AM by PaulD. Edit Reason: Added PS )

I think what you mean is that even though you would expect the required, min length and max length to apply to an incorrect input and fail on that, instead you are getting the error message for the callback, not the previous ones.

I could be wrong here, but I recall something along the lines of that callbacks get applied first. So your callback is being run first, it fails validation, and the testing stops there.

I am surprised your callback works though because you normally have to prefix it as 'callback_check_passcurr' so the validation library knows it is a callback. The function is still called check_passcurr. https://www.codeigniter.com/user_guide/l...on-methods

Sometimes, when I cannot do a callback because I need the other things validated first, I would do the validation check (required min_length etc) as per normal, and once passed validation, I do the further checks I need to do like check_passcurr, and output an error message separate from the form validation.

In my head this makes sense, as the form validation is checking the data received is in the format I expected, the further checks like is the password current, or is the code matched to a discount structure or whatever, has nothing to do with if the data is of the right form or not. It is almost as if we are trying to do too much business logic within a simple form validation. I expect 8 chars, I get 8 chars, validation passed. Whether those eight chars are matched to anything, or if they serve a particular business logic requirement or not, is not really anything to do with form input validation. I know people will have different opinions on this, just my humble opinion.

Hope that helps,

Paul

PS Just to clarify what I mean, a form submission fails when the data is not of the correct form. So a required field of max_length 20 must be there and must be less than 20 chars. However, what happens with correct data is subject to my app and the business logic. A correctly formatted but wrong code for instance might disable an account, might reset an email validation process, might trigger other alerts, might adjust prices for products etc etc. But the form does not fail in the submission, the user has filled in the form correctly. What the user sees next is up to me, they might see the form again and a message, but they might be redirected to an error page, a homepage with settings changed, logged out, banned etc etc. Too much business logic to include in a simple form validation.
Reply


Messages In This Thread
Validation callback - by rolly - 11-19-2017, 05:22 AM
RE: Validation callback - by PaulD - 11-19-2017, 07:08 AM
RE: Validation callback - by rolly - 11-20-2017, 08:02 AM
RE: Validation callback - by InsiteFX - 11-20-2017, 05:45 AM
RE: Validation callback - by rolly - 11-20-2017, 07:57 AM
RE: Validation callback - by PaulD - 11-20-2017, 08:17 AM
RE: Validation callback - by rolly - 11-21-2017, 01:26 AM



Theme © iAndrew 2016 - Forum software by © MyBB