// ...
'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') )
)
);