Welcome Guest, Not a member yet? Register   Sign In
Validation Collection
#1

[eluser]Phil Sturgeon[/eluser]
I know there are many ways in which the validation library can be improved as validation is a tricky matter, but for the purpose of this post I dont really care.

Im looking to build a compilation of useful validation extentions so we can perhaps get some of them added. Im always thinking of new ones, so to get the ball rolling...

Post: Greater Than, Less Than & Equal To

Updated: Updated link to a more useful source.

What else have you guys got eh? Making these in an extention is so much easier than using callbacks! :p
#2

[eluser]xwero[/eluser]
required_data (maybe the name should be changed to required_fields)
#3

[eluser]Référencement Google[/eluser]
Not a new feature, but I definitively had so much problems in my apps with Checkboxes, radios, select lists. There is sure a lot of things to do about it (the first would be to accept for exemple "required" for checkboxes)
#4

[eluser]Roger Glenn[/eluser]
Ditto elitemedia: we need methods for validating checkboxes and radio buttons.

Definitly checkbox_required or radio_required, but what would be really cool is having a series of rules specifically for checkboxes similar to the ones you suggested above; something like checkbox_min[1], checkbox_max[3] and checkbox_exactly[3].
#5

[eluser]xwero[/eluser]
I've added a wiki page MY_Validation so others can add/improve rules they use all the time.

I don't know if thepyromaniac had the same code for his rules but on the pastebin site there is no code to see so i added my own code. Corrections are welcome.

@mach1 : the CI validation library has sort of a validation for the checkbox_required and radio_required methods you suggested. If you use the required method the validation library will check if the field is present in the post array and will generate the required error. It means you need to make the error message more generic, which should have been done in the first place IMO.

I've added the other methods you propose but i switched the words to be consistent with the x_length rules of the validation library. The min_checked and exactly_checked methods should be used with the required method.



ps: does someone know how to remove a typo from the page name in the wiki?
#6

[eluser]Michael Wales[/eluser]
I added set_fields() to that wiki page. This allows you to call the set_fields() method and it will automatically create the appropriate fields based on the key of the rules.

Example:
Code:
$rules['username'] = 'trim|required';
$this->validation->set_rules($rules);
$this->validation->set_fields(); // Establishes "Username"

You can of course, override values - example:
Code:
$rules['username'] = 'trim|required';
$rules['email'] = 'trim|required|valid_email';
$this->validation->set_rules($rules);
$fields['email'] = 'Email Address';
$this->validation->set_fields($fields); // Establishes "Username", "Email Address" was pre-set
#7

[eluser]Phil Sturgeon[/eluser]
My pastebin times out on the code eventually. Here is the original post, but I preffer the code used in this Wiki, as numeric checks are of course a good plan.
#8

[eluser]Phil Sturgeon[/eluser]
The URL to the wiki up there is wrong.

Wiki: MY_Validation




Theme © iAndrew 2016 - Forum software by © MyBB