Please add more validator helpers.

DatDat
edited March 2011 in Feature Requests
I have to manually add this in the helper class but it would be really helpful it was permanently added to upcoming updates.

function integer($var){ if((int)($var)){ return TRUE; }else{ return FALSE; } }

Also it would be helpful to continue to add the rest of the validation rules from CI.

Thanks for all the hard work.

Comments

  • edited 11:12PM
    Could you just use the native is_int() function instead? Also, you can actually use the CI Form_validation methods if you load the library and then for the function pass the object and method as an array like so:
    $this->validator->add_rule('my_field', array($this->form_validation, 'integer', 'Please enter in an integer value')
  • DatDat
    edited 11:12PM
    Isn't this the correct way to do it?

    $this->validator->add_rule('my_field', array($this->form_validation, 'integer'), 'Please enter an integer value');

    I tried to copy and paste your code to see if it worked but it didn't, just thought i try to sort things out on this tread for future reference.

    thanks!
  • edited 11:12PM
    Yes... I missed the ending ")"
Sign In or Register to comment.