티스토리 뷰
// ... 'name' => Jelly::field('string', array( // Array for rules 'rules' => array(), )), 'name' => Jelly::field('string', array( 'rules' => array( // Add rule that only accepts the field value array('not_empty'), ), )), 'name' => Jelly::field('string', array( 'rules' => array( // Add rule that accepts parameters as well array('max_length', array(':value', 32)), ), )), // ... 'name' => Jelly::field('string', array( 'rules' => array( // Add rule that only accepts the field value array('is_writable'), ), )) // ... 'name' => Jelly::field('string', array( 'rules' => array( // Add rule that accepts parameters as well array('mb-check-encoding', array(':value', 'UTF-8')), ), )), try { $user = Jelly::factory('user'); $user->username = 'invalid username'; $user->save(); } catch (Jelly_Validation_Exception $e) { // Get the error messages $errors = $e->errors(); } public function action_create() { try { $user = Jelly::factory('user'); $user->username = $_POST['username']; $user->password = $_POST['password']; $extra_rules = Validation::factory($_POST) ->rule('password_confirm', 'matches', array( ':validation', ':field', 'password' )); // Pass the extra rules to be validated with the model $user->save($extra_rules); } catch (Jelly_Validation_Exception $e) { $errors = $e->errors('models'); } } public function action_create_twitter() { $user = Jelly::factory('user'); $user->username = $_POST['twitter_id']; $user->save(FALSE); } try { $model = Jelly::factory('sample'); $post['name'] = ""; $post['description'] = "한글한글"; $post['act'] = "333"; $post['kk'] = "333"; $rules = Jelly_Validation::factory($post)->rule('name', 'not_empty'); $model->save($rules); } catch ( Jelly_Validation_Exception $e ) { $errors = $e->errors('models'); echo ""; print_r($errors); echo " "; exit; } return Validation::factory($values) ->rule('password', 'min_length', array(':value', 6)) ->rule('password_confirm', 'matches', array(':validation', ':field', 'password')); return array( 'user_id' => array( array('not_empty'), array('numeric') ), 'provider' => array( array('not_empty'), array('max_length', array(':value', 255) ) ), 'identity' => array( array('not_empty'), array('max_length', array(':value', 255) ), array(array($this, 'unique_identity'), array(':validation', ':field') ) ) );
'웹개발 > Php' 카테고리의 다른 글
이클립스 PDT 주석 설정 (0) | 2012.03.02 |
---|---|
ckFinder 설정 (0) | 2012.03.01 |
Kohana 3.2 Jelly 사용하기 (0) | 2012.02.25 |
Kohana module init 설정 내용 예제들 (0) | 2012.02.18 |
에디트 플러스 와 phpunit 연동 테스팅 하기 (0) | 2012.02.04 |
댓글