Beispiel #1
0
 /**
  * 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()
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 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.'), 'allowEmpty' => false, 'on' => 'update')), 'file_id' => array('numeric' => array('rule' => array('numeric'), 'message' => __d('net_commons', 'Invalid request.'), 'allowEmpty' => true)), 'is_auto_translated' => array('boolean' => array('rule' => array('boolean'), 'message' => __d('net_commons', 'Invalid request.'))), 'name' => array('notBlank' => array('rule' => array('notBlank'), 'message' => sprintf(__d('net_commons', 'Please input %s.'), __d('edumap', 'School name')), 'required' => true)), 'handle' => array('notBlank' => array('rule' => array('notBlank'), 'message' => sprintf(__d('net_commons', 'Please input %s.'), __d('edumap', 'Handle name')))), 'postal_code' => array('notBlank' => array('rule' => array('notBlank'), 'message' => sprintf(__d('net_commons', 'Please input %s.'), __d('edumap', 'Postal code'))), 'postal' => array('rule' => '/^\\d{3}-\\d{4}$/', 'message' => sprintf(__d('net_commons', 'Unauthorized pattern for %s. Please input the data in %s format.'), __d('edumap', 'Postal code'), '999-9999'))), 'prefecture_code' => array('notBlank' => array('rule' => array('notBlank'), 'message' => sprintf(__d('net_commons', 'Please input %s.'), __d('edumap', 'Prefecture'))), 'prefectureCode' => array('rule' => '/^0[1-9]|[1-3]\\d|4[0-7]$/i', 'message' => __d('net_commons', 'Invalid request.'))), 'location' => array('notBlank' => array('rule' => array('notBlank'), 'message' => sprintf(__d('net_commons', 'Please input %s.'), __d('edumap', 'Location')))), 'tel' => array('notBlank' => array('rule' => array('notBlank'), 'message' => sprintf(__d('net_commons', 'Please input %s.'), __d('edumap', 'Phone number'))), 'phone' => array('rule' => '/^0\\d{1,4}-\\d{1,4}-\\d{1,4}$/', 'message' => sprintf(__d('net_commons', 'Unauthorized pattern for %s. Please input the data in %s format.'), __d('edumap', 'Phone number'), __d('edumap', 'Phone number')))), 'fax' => array('phone' => array('rule' => '/^0\\d{1,4}-\\d{1,4}-\\d{1,4}$/', 'message' => sprintf(__d('net_commons', 'Unauthorized pattern for %s. Please input the data in %s format.'), __d('edumap', 'Fax number'), __d('edumap', 'Fax number')), 'allowEmpty' => true)), 'emergency_email' => array('notBlank' => array('rule' => array('notBlank'), 'message' => sprintf(__d('net_commons', 'Please input %s.'), __d('edumap', 'Emergency contact email'))), 'email' => array('rule' => array('email'), 'message' => sprintf(__d('net_commons', 'Unauthorized pattern for %s. Please input the data in %s format.'), __d('edumap', 'Emergency contact email'), __d('edumap', 'E-mail')))), 'site_url' => array('url' => array('rule' => array('url'), 'message' => sprintf(__d('net_commons', 'Unauthorized pattern for %s. Please input the data in %s format.'), __d('edumap', 'Site URL'), __d('edumap', 'URL')), 'allowEmpty' => true)), 'rss_url' => array('url' => array('rule' => array('url'), 'message' => sprintf(__d('net_commons', 'Unauthorized pattern for %s. Please input the data in %s format.'), __d('edumap', 'RSS URL'), __d('edumap', 'URL')), 'allowEmpty' => true)), 'foundation_date' => array('date' => array('rule' => array('date', 'ym'), 'message' => sprintf(__d('net_commons', 'Unauthorized pattern for %s. Please input the data in %s format.'), __d('edumap', 'Foundation date'), __d('edumap', 'Date')), 'allowEmpty' => true)), 'closed_date' => array('date' => array('rule' => array('date', 'ym'), 'message' => sprintf(__d('net_commons', 'Unauthorized pattern for %s. Please input the data in %s format.'), __d('edumap', 'Closed date'), __d('edumap', 'Date')), 'allowEmpty' => true)), 'principal_email' => array('email' => array('rule' => array('email'), 'message' => sprintf(__d('net_commons', 'Unauthorized pattern for %s. Please input the data in %s format.'), __d('edumap', 'Principal email'), __d('edumap', 'E-mail')), 'allowEmpty' => true))));
     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('type' => array('notBlank' => array('rule' => array('notBlank'), 'message' => __d('net_commons', 'Invalid request.'), 'allowEmpty' => false, 'required' => true), 'inList' => array('rule' => array('inList', array(self::SOCIAL_TYPE_TWITTER)), 'message' => __d('net_commons', 'Invalid request.'))), 'value' => array('notBlank' => array('rule' => array('notBlank'), 'message' => __d('net_commons', 'Invalid request.'), 'allowEmpty' => false, 'required' => true), 'alphaNumeric' => array('rule' => '/^[0-9a-z]+$/i', 'message' => __d('net_commons', 'Only alphabets and numbers are allowed.'), 'allowEmpty' => 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 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('edumap_key' => array('notBlank' => array('rule' => array('notBlank'), 'message' => __d('net_commons', 'Invalid request.'), 'allowEmpty' => false))));
     return parent::beforeValidate($options);
 }
Beispiel #4
0
 /**
  * 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('gendar' => array('boolean' => array('rule' => array('boolean'), 'message' => __d('net_commons', 'Invalid request.'), 'required' => true)), 'grade' => array('numeric' => array('rule' => array('numeric'), 'message' => __d('net_commons', 'Invalid request.'), 'allowEmpty' => false, 'required' => true)), 'number' => array('numeric' => array('rule' => array('numeric'), 'message' => __d('net_commons', 'Invalid request.'), 'allowEmpty' => false, 'required' => true))));
     return parent::beforeValidate($options);
 }