Skip to content

Instantly share code, notes, and snippets.

@uppfinnarjohnny
Created April 10, 2012 13:12
Show Gist options
  • Save uppfinnarjohnny/2351256 to your computer and use it in GitHub Desktop.
Save uppfinnarjohnny/2351256 to your computer and use it in GitHub Desktop.
Validation rules for Kohana 3.2 (kinda)
<?php
class RegistrationForm extends Validation {
public function __construct(Array $array) {
parent::__construct($array);
$this->rule('username', 'not_empty');
$this->rule('password', 'not_empty');
$this->rule('password_confirmation', 'matches', array(':validation', 'confirm', 'password'));
}
public function check() {
$this['username'] = trim($this['username']);
return parent::__check();
}
public function offsetSet($offset, $value) {
$this->_data[$offset] = $value;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment