public function beforeValidate($options = array()) { parent::beforeValidate($options); $this->validate['Name']['notempty']['message'] = __d('contactform', 'please insert your name'); $this->validate['Mail']['email']['message'] = __d('contactform', 'please insert your email address'); $this->validate['Message']['notempty']['message'] = __d('contactform', 'please enter your message'); }
public function beforeValidate() { parent::beforeValidate(); if (isset($this->data[$this->alias]['url']) && !isset($this->data[$this->alias]['study_name'])) { $this->data[$this->alias]['study_name'] = $this->getTitle($this->data[$this->alias]['url']); } if (isset($this->data[$this->alias]['tag_list'])) { preg_match_all('/\\[([^\\]]*)\\]/', $this->data[$this->alias]['tag_list'], $matches); if (isset($matches[1])) { $this->data['Tag']['Tag'] = array(); foreach ($matches[1] as $tag) { $tagValue = mb_convert_kana($tag, 'as'); $conditions = array('LOWER(Tag.tag)' => strtolower($tagValue)); $this->Tag->contain(); $this->Tag->foreignKey(); $tag_id = $this->Tag->field('id', $conditions); if (!$tag_id) { $data = array('Tag' => array('tag' => $tagValue)); $this->Tag->create(); if (!$this->Tag->save($data)) { return false; } $tag_id = $this->Tag->getInsertID(); } $this->data['Tag']['Tag'][] = $tag_id; } } unset($this->data[$this->alias]['tag_list']); } return true; }
/** * Handle beforeValidate callback * * @return void * @author hungnq **/ public function beforeValidate($options = array()) { if (isset($this->data[$this->name]['tel']) && is_array($this->data[$this->name]['tel'])) { $this->data[$this->name]['tel'] = implode('', array_filter($this->data[$this->name]['tel'])); } return parent::beforeValidate($options); }
function beforeValidate() { if (!parent::beforeValidate()) { return false; } $this->loadValidation(); }
/** * beforeValidate callback * * @param array $options * @return boolean * @access public * @todo implement check of approved_from/approved_to */ public function beforeValidate($options = array()) { if (!parent::beforeValidate($options)) { return false; } return true; }
/** * CakePHP's beforeValidate callback. * * @return boolean * @access public */ public function beforeValidate() { parent::beforeValidate(); if (!empty($this->data)) { /** * An empty password value is never empty. The Auth module hashes * the empty value which makes it non-empty and fools the notEmpty * validation rule. This is bad. * * We want to recognize an empty password when we see one and * throw it out, so we have to make that adjustment manually. */ $empty_password = Security::hash('', null, true); if (isset($this->data[$this->alias]['password']) && $this->data[$this->alias]['password'] === $empty_password) { if (!empty($this->id)) { # When editing, just remove the data so no change is attempted. unset($this->data[$this->alias]['password']); unset($this->data[$this->alias]['confirm_password']); } else { # When creating, empty the value so it will be caught by validation. $this->data[$this->alias]['password'] = ''; $this->data[$this->alias]['confirm_password'] = ''; } } } return true; }
public function beforeValidate($options = array()) { parent::beforeValidate(); if ($this->data['User']['password'] == '') { unset($this->data['User']['password']); } return true; }
/** * Before Validation * @param array $options * @return boolean */ public function beforeValidate($options = array()) { // ignore empty file - causes issues with form validation when file is empty and optional if (!empty($this->data[$this->alias]['filename']['error']) && $this->data[$this->alias]['filename']['error'] == 4 && $this->data[$this->alias]['filename']['size'] == 0) { unset($this->data[$this->alias]['filename']); } parent::beforeValidate($options); }
public function beforeValidate($options = array()) { parent::beforeValidate($options); if (isset($this->data[$this->alias]['product_exchange_id'])) { $product = $this->ProductExchange->find('first', array('recursive' => -1, 'conditions' => array('ProductExchange.id' => $this->data[$this->alias]['product_exchange_id']), 'fields' => array('point_fee', 'money_fee', 'point_exchange', 'product_category_id', 'min_point_gift', 'min_point_money', 'exchange_gift_rate'))); $this->data['ProductExchange'] = array('point_fee' => intval($product['ProductExchange']['point_fee']), 'money_fee' => intval($product['ProductExchange']['money_fee']), 'point_exchange' => $product['ProductExchange']['point_exchange'], 'product_category_id' => $product['ProductExchange']['product_category_id'], 'min_point_gift' => intval($product['ProductExchange']['min_point_gift']), 'min_point_money' => intval($product['ProductExchange']['min_point_money']), 'exchange_gift_rate' => $product['ProductExchange']['exchange_gift_rate']); } }
public function beforeValidate($options = array()) { if (isset($this->data[$this->alias]['email'])) { // Always store email in lowercase $this->data[$this->alias]['email'] = strtolower($this->data[$this->alias]['email']); } return parent::beforeValidate($options); }
public function beforeValidate($options = array()) { parent::beforeValidate(); $date = date('Y-m-d H:i:s'); if (empty($this->data['EventBlacklist']['id'])) { $this->data['EventBlacklist']['date_created'] = $date; } return true; }
public function beforeValidate($options = array()) { $name = $this->data[$this->alias]['name']; switch ($name) { default: break; } return parent::beforeValidate($options); }
/** * Called during validation operations, before validation. Please note that custom * validation rules can be defined in $validate. * * @param array $options Options passed from Model::save(). * @return bool True if validate operation should continue, false to abort * @link http://book.cakephp.org/2.0/en/models/callback-methods.html#beforevalidate * @see Model::save() */ public function beforeValidate($options = array()) { $forgotPass = CakeSession::read('ForgotPass'); if (!$forgotPass) { $forgotPass = array(); } $this->validate = Hash::merge($this->validate, array('email' => array('notBlank' => array('rule' => array('notBlank'), 'message' => __d('net_commons', 'Please input %s.', __d('auth', 'email')), 'required' => false), 'email' => array('rule' => array('email'), 'message' => sprintf(__d('net_commons', 'Unauthorized pattern for %s. Please input the data in %s format.'), __d('auth', 'email'), __d('auth', 'email')))), 'authorization_key' => array('notBlank' => array('rule' => array('notBlank'), 'message' => __d('net_commons', 'Please input %s.', __d('auth', 'Authorization key')), 'required' => false), 'equalTo' => array('rule' => array('equalTo', Hash::get($forgotPass, 'authorization_key')), 'message' => __d('auth', 'Failed on validation errors. Please check the authorization key.'), 'required' => false)))); return parent::beforeValidate($options); }
/** * Called during validation operations, before validation. Please note that custom * validation rules can be defined in $validate. * * @param array $options Options passed from Model::save(). * * @return boolean True if validate operation should continue, false to abort * @see Model::save() */ public function beforeValidate($options = []) { parent::beforeValidate($options); if (Router::getParam('action') == 'admin_profile') { if ($this->data['User']['password'] == "" && $this->data['User']['confirm_password'] == "") { unset($this->data['User']['password']); unset($this->data['User']['confirm_password']); } } }
/** * Antes de validar as informações * * @return boolean */ public function beforeValidate($options = array()) { if (isset($this->data[$this->alias]['twitter'])) { $twitter = $this->data[$this->alias]['twitter']; $twitter = trim($twitter); $twitter = trim($twitter, '@'); $this->data[$this->alias]['twitter'] = $twitter; } return parent::beforeValidate($options); }
public function beforeValidate($options = array()) { parent::beforeValidate(); $schema = $this->schema(); if (!isset($schema['event_info'])) { $this->updateDatabase('addEventBlacklistsContext'); } $date = date('Y-m-d H:i:s'); if (empty($this->data['EventBlacklist']['id'])) { $this->data['EventBlacklist']['date_created'] = $date; } return true; }
public function beforeValidate($options = array()) { parent::beforeValidate(); }
/** * Called during validation operations, before validation. Please note that custom * validation rules can be defined in $validate. * * @param array $options Options passed from Model::save(). * @return bool True if validate operation should continue, false to abort * @link http://book.cakephp.org/2.0/en/models/callback-methods.html#beforevalidate * @see Model::save() */ public function beforeValidate($options = array()) { //入力キーのチェック if (SiteSettingUtil::read('AutoRegist.use_secret_key')) { $this->validate = Hash::merge($this->validate, array('secret_key' => array('notBlank' => array('rule' => array('notBlank'), 'message' => sprintf(__d('net_commons', 'Please input %s.'), __d('auth', 'Secret key')), 'required' => true), 'equalTo' => array('rule' => array('equalTo', SiteSettingUtil::read('AutoRegist.secret_key')), 'message' => __d('auth', 'Failed on validation errors. Please check the secret key.'), 'required' => true)))); } return parent::beforeValidate($options); }
/** * beforeValidate callback * * @param type $options * @return array */ public function beforeValidate($options = array()) { $this->data = $this->cleanInputData($this->data); return parent::beforeValidate($options); }
public function beforeValidate($options = array()) { parent::beforeValidate(); // analysis - setting correct vars // TODO refactor analysis into an Enum (in the database) if (isset($this->data['Event']['analysis'])) { switch ($this->data['Event']['analysis']) { case 'Initial': $this->data['Event']['analysis'] = 0; break; case 'Ongoing': $this->data['Event']['analysis'] = 1; break; case 'Completed': $this->data['Event']['analysis'] = 2; break; } } // generate UUID if it doesn't exist if (empty($this->data['Event']['uuid'])) { $this->data['Event']['uuid'] = String::uuid(); } // generate timestamp if it doesn't exist if (empty($this->data['Event']['timestamp'])) { $date = new DateTime(); $this->data['Event']['timestamp'] = $date->getTimestamp(); } }
/** * Before Validation Callback * @param array $options * @return boolean */ public function beforeValidate($options = array()) { return parent::beforeValidate($options); }
public function beforeValidate($options = array()) { parent::beforeValidate(); // remove leading and trailing blanks //$this->trimStringFields(); // TODO if (isset($this->data['ShadowAttribute']['value'])) { $this->data['ShadowAttribute']['value'] = trim($this->data['ShadowAttribute']['value']); } if (!isset($this->data['ShadowAttribute']['type'])) { return false; } if (empty($this->data['ShadowAttribute']['timestamp'])) { $date = new DateTime(); $this->data['ShadowAttribute']['timestamp'] = $date->getTimestamp(); } switch ($this->data['ShadowAttribute']['type']) { // lowercase these things case 'md5': case 'sha1': case 'domain': case 'hostname': $this->data['ShadowAttribute']['value'] = strtolower($this->data['ShadowAttribute']['value']); break; case 'filename|md5': case 'filename|sha1': $pieces = explode('|', $this->data['ShadowAttribute']['value']); $this->data['ShadowAttribute']['value'] = $pieces[0] . '|' . strtolower($pieces[1]); break; } // generate UUID if it doesn't exist if (empty($this->data['ShadowAttribute']['uuid'])) { $this->data['ShadowAttribute']['uuid'] = $this->generateUuid(); } // always return true, otherwise the object cannot be saved return true; }
/** * Called during validation operations, before validation. Please note that custom * validation rules can be defined in $validate. * * @param array $options Options passed from Model::save(). * @return bool True if validate operation should continue, false to abort * @link http://book.cakephp.org/2.0/en/models/callback-methods.html#beforevalidate * @see Model::save() */ public function beforeValidate($options = array()) { $this->validate = Hash::merge($this->validate, array('key' => array('notBlank' => array('rule' => array('notBlank'), 'message' => __d('net_commons', 'Invalid request.'))), 'frame_id' => array('numeric' => array('rule' => array('numeric'), 'message' => __d('net_commons', 'Invalid request.'))), 'unit_type' => array('boolean' => array('rule' => array('boolean'), 'message' => __d('net_commons', 'Invalid request.'))), 'display_days' => array('numeric' => array('rule' => array('numeric'), 'message' => __d('net_commons', 'Invalid request.'))), 'display_number' => array('numeric' => array('rule' => array('numeric'), 'message' => __d('net_commons', 'Invalid request.'))), 'display_title' => array('boolean' => array('rule' => array('boolean'), 'message' => __d('net_commons', 'Invalid request.'))), 'display_room_name' => array('boolean' => array('rule' => array('boolean'), 'message' => __d('net_commons', 'Invalid request.'))), 'display_plugin_name' => array('boolean' => array('rule' => array('boolean'), 'message' => __d('net_commons', 'Invalid request.'))), 'display_created_user' => array('boolean' => array('rule' => array('boolean'), 'message' => __d('net_commons', 'Invalid request.'))), 'display_created' => array('boolean' => array('rule' => array('boolean'), 'message' => __d('net_commons', 'Invalid request.'))), 'display_description' => array('boolean' => array('rule' => array('boolean'), 'message' => __d('net_commons', 'Invalid request.'))), 'select_room' => array('boolean' => array('rule' => array('boolean'), 'message' => __d('net_commons', 'Invalid request.'))), 'show_my_room' => array('boolean' => array('rule' => array('boolean'), 'message' => __d('net_commons', 'Invalid request.'))), 'created_user' => array('numeric' => array('rule' => array('numeric'), 'message' => __d('net_commons', 'Invalid request.'))), 'modified_user' => array('numeric' => array('rule' => array('numeric'), 'message' => __d('net_commons', 'Invalid request.'))))); return parent::beforeValidate($options); }
/** * Called during validation operations, before validation. Please note that custom * validation rules can be defined in $validate. * * @param array $options Options passed from Model::save(). * @return bool True if validate operation should continue, false to abort * @link http://book.cakephp.org/2.0/en/models/callback-methods.html#beforevalidate * @see Model::save() */ public function beforeValidate($options = array()) { // この継承クラスたちがValidateロジックを走らせる前に必ずDBを切り替える $this->setDataSource('master'); return parent::beforeValidate($options); }
public function beforeValidate($options = array()) { parent::beforeValidate(); // remove leading and trailing blanks $this->data['Attribute']['value'] = trim($this->data['Attribute']['value']); if (!isset($this->data['Attribute']['type'])) { return false; } switch ($this->data['Attribute']['type']) { // lowercase these things case 'md5': case 'sha1': case 'sha256': case 'domain': case 'hostname': $this->data['Attribute']['value'] = strtolower($this->data['Attribute']['value']); break; case 'filename|md5': case 'filename|sha1': case 'filename|sha256': $pieces = explode('|', $this->data['Attribute']['value']); $this->data['Attribute']['value'] = $pieces[0] . '|' . strtolower($pieces[1]); break; } // uppercase the following types switch ($this->data['Attribute']['type']) { case 'http-method': $this->data['Attribute']['value'] = strtoupper($this->data['Attribute']['value']); break; } // set to_ids if it doesn't exist if (empty($this->data['Attribute']['to_ids'])) { $this->data['Attribute']['to_ids'] = 0; } // generate UUID if it doesn't exist if (empty($this->data['Attribute']['uuid'])) { $this->data['Attribute']['uuid'] = String::uuid(); } // generate timestamp if it doesn't exist if (empty($this->data['Attribute']['timestamp'])) { $date = new DateTime(); $this->data['Attribute']['timestamp'] = $date->getTimestamp(); } $result = $this->runRegexp($this->data['Attribute']['type'], $this->data['Attribute']['value']); if (!$result) { $this->invalidate('value', 'This value is blocked by a regular expression in the import filters.'); } else { $this->data['Attribute']['value'] = $result; } // always return true, otherwise the object cannot be saved return true; }
public function beforeValidate($options = array()) { parent::beforeValidate($options); $this->_prepareValidationRules(); }
/** * Called during validation operations, before validation. Please note that custom * validation rules can be defined in $validate. * * @param array $options Options passed from Model::save(). * @return bool True if validate operation should continue, false to abort * @link http://book.cakephp.org/2.0/en/models/callback-methods.html#beforevalidate * @see Model::save() */ public function beforeValidate($options = array()) { $this->validate = Hash::merge($this->validate, array('name' => array('notBlank' => array('rule' => array('notBlank'), 'message' => sprintf(__d('net_commons', 'Please input %s.'), __d('pages', 'Page name')), 'required' => true)), 'page_id' => array('numeric' => array('rule' => array('numeric'), 'message' => __d('net_commons', 'Invalid request.'))), 'language_id' => array('numeric' => array('rule' => array('numeric'), 'message' => __d('net_commons', 'Invalid request.'))))); return parent::beforeValidate($options); }
/** * バリデートメッセージ多言語化対応のためのラップ * * @param array $options options * @return bool */ public function beforeValidate($options = array()) { $this->validate = Hash::merge($this->validate, $this->_getValidateSpecification()); return parent::beforeValidate($options); }
/** * Called during validation operations, before validation. Please note that custom * validation rules can be defined in $validate. * * @param array $options Options passed from Model::save(). * @return bool True if validate operation should continue, false to abort * @link http://book.cakephp.org/2.0/en/models/callback-methods.html#beforevalidate * @see Model::save() */ public function beforeValidate($options = array()) { $this->validate = Hash::merge($this->validate, array('block_id' => array('numeric' => array('rule' => array('numeric'), 'message' => __d('net_commons', 'Invalid request.'))), 'key' => array('notBlank' => array('rule' => array('notBlank'), 'message' => __d('net_commons', 'Invalid request.'))), 'status' => array('numeric' => array('rule' => array('numeric'), 'message' => __d('net_commons', 'Invalid request.'))), 'is_active' => array('boolean' => array('rule' => array('boolean'), 'message' => __d('net_commons', 'Invalid request.'))), 'is_latest' => array('boolean' => array('rule' => array('boolean'), 'message' => __d('net_commons', 'Invalid request.'))), 'is_auto_translated' => array('boolean' => array('rule' => array('boolean'), 'message' => __d('net_commons', 'Invalid request.'))), 'is_first_auto_translation' => array('boolean' => array('rule' => array('boolean'), 'message' => __d('net_commons', 'Invalid request.'))), 'plugin_key' => array('notBlank' => array('rule' => array('notBlank'), 'message' => __d('net_commons', 'Invalid request.'))), 'title' => array('notBlank' => array('rule' => array('notBlank'), 'message' => __d('net_commons', 'Invalid request.'))), 'contents' => array('notBlank' => array('rule' => array('notBlank'), 'message' => __d('net_commons', 'Invalid request.'))), 'path' => array('notBlank' => array('rule' => array('notBlank'), 'message' => __d('net_commons', 'Invalid request.'))), 'created_user' => array('numeric' => array('rule' => array('numeric'), 'message' => __d('net_commons', 'Invalid request.'))), 'modified_user' => array('numeric' => array('rule' => array('numeric'), 'message' => __d('net_commons', 'Invalid request.'))))); return parent::beforeValidate($options); }
/** * beforeValidate callback * * @param array $options * @return boolean * @access public */ public function beforeValidate($options = array()) { if (!parent::beforeValidate($options)) { return false; } foreach (array('name', 'payment_method', 'payment_target') as $field) { if (isset($this->data[$this->alias][$field]) && empty($this->data[$this->alias][$field])) { $this->data[$this->alias][$field] = null; } } return true; }