Esempio n. 1
0
 /**
  * beforeValidate
  *
  * @param array $options options
  * @return bool
  */
 public function beforeValidate($options = array())
 {
     // 拡張子チェック
     $uploadAllowExtension = $this->getAllowExtension();
     $this->validate['real_file_name']['extension'] = ['rule' => ['isValidExtension', $uploadAllowExtension, false], 'message' => __d('files', 'It is upload disabled file format')];
     $this->validate['real_file_name']['size'] = 'validateRoomFileSizeLimit';
     return parent::beforeValidate($options);
 }
Esempio n. 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()
  */
 public function beforeValidate($options = array())
 {
     $postMaxSize = CakeNumber::fromReadableSize(ini_get('post_max_size'));
     $uploadMaxFilesize = CakeNumber::fromReadableSize(ini_get('upload_max_filesize'));
     $maxUploadSize = CakeNumber::toReadableSize($postMaxSize > $uploadMaxFilesize ? $uploadMaxFilesize : $postMaxSize);
     $this->validate = Hash::merge($this->validate, array(self::INPUT_NAME => array('uploadError' => array('rule' => array('uploadError'), 'message' => array('Error uploading file'))), 'name' => array('notBlank' => array('rule' => array('notBlank'), 'message' => __d('net_commons', 'Invalid request.'), 'allowEmpty' => false, 'required' => true)), 'slug' => array('notBlank' => array('rule' => array('notBlank'), 'message' => __d('net_commons', 'Invalid request.'), 'allowEmpty' => false, 'required' => true)), 'path' => array('notBlank' => array('rule' => array('notBlank'), 'message' => __d('net_commons', 'Invalid request.'), 'allowEmpty' => false, 'on' => 'create')), 'extension' => array('notBlank' => array('rule' => array('notBlank'), 'message' => __d('net_commons', 'Invalid request.'), 'allowEmpty' => false, 'required' => true)), 'mimetype' => array('notBlank' => array('rule' => array('notBlank'), 'message' => __d('net_commons', 'Invalid request.'), 'allowEmpty' => false)), 'size' => array('numeric' => array('rule' => array('numeric'), 'message' => __d('net_commons', 'Invalid request.'), 'allowEmpty' => false)), 'role_type' => array('notBlank' => array('rule' => array('notBlank'), 'message' => __d('net_commons', 'Invalid request.'), 'allowEmpty' => false, 'required' => true)), 'number_of_downloads' => array('numeric' => array('rule' => array('numeric'), 'message' => __d('net_commons', 'Invalid request.'))), 'status' => array('numeric' => array('rule' => array('numeric'), 'message' => __d('net_commons', 'Invalid request.')))));
     return parent::beforeValidate($options);
 }
Esempio n. 3
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('name' => array('notBlank' => array('rule' => array('notBlank'), 'message' => __d('net_commons', 'Invalid request.'), 'allowEmpty' => false, 'required' => true)), 'slug' => array('notBlank' => array('rule' => array('notBlank'), 'message' => __d('net_commons', 'Invalid request.'), 'allowEmpty' => false, 'required' => true)), 'path' => array('notBlank' => array('rule' => array('notBlank'), 'message' => __d('net_commons', 'Invalid request.'), 'allowEmpty' => false, 'on' => 'create')), 'extension' => array('notBlank' => array('rule' => array('notBlank'), 'message' => __d('net_commons', 'Invalid request.'), 'allowEmpty' => false, 'required' => true)), 'mimetype' => array('notBlank' => array('rule' => array('notBlank'), 'message' => __d('net_commons', 'Invalid request.'), 'allowEmpty' => false)), 'size' => array('numeric' => array('rule' => array('numeric'), 'message' => __d('net_commons', 'Invalid request.'), 'allowEmpty' => false)), 'role_type' => array('notBlank' => array('rule' => array('notBlank'), 'message' => __d('net_commons', 'Invalid request.'), 'allowEmpty' => false, 'required' => true)), 'number_of_downloads' => array('numeric' => array('rule' => array('numeric'), 'message' => __d('net_commons', 'Invalid request.'))), 'status' => array('numeric' => array('rule' => array('numeric'), 'message' => __d('net_commons', 'Invalid request.')))));
     return parent::beforeValidate($options);
 }