Jump to content

flexrocks

New Members
  • Posts

    1
  • Joined

  • Last visited

flexrocks's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. So i have a pretty basic form validator that checks if the field is valid but i'm having hard time trying to implement rules. i have already implemented a few rules but how can i implement max_length and min_length? here is my validate function public function validate($field,$value,$rules) { $field = ucfirst($field); $rules = explode('|',$rules); foreach($rules as $rule) { switch($rule) { case 'required': $this->shouldBeRequired($field, $value); break; case 'string': $this->shouldBeString($field,$value); break; case 'email': $this->shouldBeEmail($field, $value); break; case 'number': $this->shouldBeNumber($field,$value); // default: // throw new ErrorException("$rule doesn't exist"); } } } i want to do case 'max_length' but i have no idea how. the rule should look like this max_length:60|required any help is appreciated
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.