示例#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('is_variable' => array('boolean' => array('rule' => array('boolean'), 'allowEmpty' => false, 'required' => true, 'message' => __d('net_commons', 'Invalid request.'))), 'can_substitute' => array('boolean' => array('rule' => array('boolean'))), 'month_day' => array('date' => array('rule' => array('date', 'ymd'), 'message' => __d('net_commons', 'Invalid request.'), 'allowEmpty' => false, 'required' => true)), 'week' => array('inList' => array('rule' => array('inList', array_keys(HolidaysComponent::getWeekSelectList())), 'message' => __d('net_commons', 'Invalid request.'), 'allowEmpty' => true, 'required' => false)), 'day_of_the_week' => array('inList' => array('rule' => array('inList', array_keys(HolidaysComponent::getWeekdaySelectList())), 'message' => __d('net_commons', 'Invalid request.'), 'allowEmpty' => true, 'required' => false)), 'start_year' => array('date' => array('rule' => array('date'), 'message' => __d('net_commons', 'Invalid request.'), 'allowEmpty' => true)), 'end_year' => array('date' => array('rule' => array('date'), 'message' => __d('net_commons', 'Invalid request.'), 'allowEmpty' => true), 'comparison' => array('rule' => array('comparison', '>', $this->data['HolidayRrule']['start_year']), 'message' => __d('holidays', 'Please input the end year is bigger than start year.')))));
     parent::beforeValidate($options);
     return true;
 }
示例#2
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('holiday_rrule_id' => array('numeric' => array('rule' => array('numeric'), 'message' => __d('net_commons', 'Invalid request.'), 'allowEmpty' => false, 'required' => true)), 'language_id' => array('numeric' => array('rule' => array('numeric'), 'message' => __d('net_commons', 'Invalid request.'), 'allowEmpty' => false, 'required' => true)), 'holiday' => array('date' => array('rule' => 'date', 'message' => __d('net_commons', 'Invalid request.'), 'allowEmpty' => false, 'required' => true)), 'title' => array('notBlank' => array('rule' => array('notBlank'), 'message' => __d('holidays', 'Please input title.'), 'allowEmpty' => false, 'required' => true)), 'is_substitute' => array('boolean' => array('rule' => array('boolean'), 'message' => __d('net_commons', 'Invalid request.'), 'allowEmpty' => true, 'required' => false))));
     parent::beforeValidate($options);
     return true;
 }