Welcome Guest, Not a member yet? Register   Sign In
Validation sum of input
#6

(This post was last modified: 06-05-2017, 11:38 AM by PaulD.)

I am not sure this will help at all, but I would consider that this is your business logic and not a form_validation process. All the form_validation does is make sure you are getting the data formats you expected. After that, your business logic might demand that the submitted data adds up to 100, your business logic tested, you would then process your page however you need to after that, including returning your own error messages that are not part of the form validation routines, even though they would be shown on your form page.

For instance, your business logic might get more complicated in the future, where some accounts are allowed 150, or only 50 during a trial period. Or perhaps a temp process where anything below 100 is allowed. Whatever the reason for the 100 total, I would say this is business logic and should be done after the form_validation has checked the data are integers, of a max and min length etc.

ps array_sum is a great function. I thought it might generate an error with 'hello' in the array but it just ignores it. Never used it myself but just had a play with it on phpfiddle, great function.
Reply


Messages In This Thread
Validation sum of input - by kenji - 06-03-2017, 08:20 AM
RE: Validation sum of input - by Avenirer - 06-04-2017, 07:50 AM
RE: Validation sum of input - by kenji - 06-04-2017, 07:58 AM
RE: Validation sum of input - by Wouter60 - 06-04-2017, 01:01 PM
RE: Validation sum of input - by lloricode - 06-04-2017, 08:34 PM
RE: Validation sum of input - by PaulD - 06-05-2017, 11:32 AM



Theme © iAndrew 2016 - Forum software by © MyBB