Feature #217

add $source_param['option_name']['range'] in the lookup source

Added by patrick_elx over 2 years ago. Updated 12 months ago.

Status:Feedback Start:10/28/2009
Priority:Low Due date:
Assigned to:- % Done:

0%

Category:-
Target version:Caller ID Superfecta - Future Versions

Description

To follow up on feature #194, should we try to make the module more userproof regarding option inputs by testing user entry before accepting it?

We can define the following source tags for instance:
$source_param['option_name']['min']
$source_param['option_name']['max']
that will be tested with a simple if (($value<min) or ($value>max)) -> error

$source_param['option_name']['minlenght']
$source_param['option_name']['maxlenght']
that will be tested against a if ((strlength($value)<minlenght) or ((strlength($value)>maxlenght)) -> error

if error, do not accept the change and keep the previous value, display an error comment.

History

Updated by tshif over 2 years ago

  • Status changed from New to Reviewed

Updated by jacobsj about 2 years ago

How are min & max defined? are these numeric values? Or should it accept a min of aaa and a max of zzz and force the user to enter a 3 letter word?

Because of the wide range of possible restrictions one might want to put on an entry, what if we approached this differently. What if each source file contained validation functions for each variable that could be run and return a string or false.

For example the source file source-Open79XX.php could contain the function Open79XX_DB_Password($value)
And this function could validate the entered value any way it pleased to make sure that it was correct. If the value was correctly entered the function could return $value and if the value was incorrectly entered it could return false.

This would allow source designers to do more complex entry validation like validating an email address if needed.

Updated by tshif about 1 year ago

jkiel - I would enjoy hearing your thoughts on this when you have time. No rush for sure.

Updated by tshif about 1 year ago

  • Status changed from Reviewed to Feedback

Updated by jkiel about 1 year ago

For 2.x, I say leave it as it.

For 3.x, it would be nice to be able to define user input with finer grain -- but exactly how will need more thought. Moving to a class will open up many more options on how this is defined, stored and validated. For example, the source module could contain its own form validation logic rather than depending on page.superfecta.php and sources.php (or what will be their replacements) to do it all. Of course, page.superfecta.php/sources.php should still do some of the basics to make source development as easy as possible --- but fringe cases may be able to be handled by the source itself.

Updated by ukstevef 12 months ago

I have found a flexible javascript to vaidate forms at http://www.javascript-coder.com/html-form/javascript-form-validation.phtml

Looking through the examples we could even do cross validation of fields and use regexp to check values.

Also available in: Atom PDF