Example #1
0
 public static function _validation_unique($val, $options)
 {
     list($table, $field) = explode('.', $options);
     $result = DB::select("LOWER (\"{$field}\")")->where($field, '=', Str::lower($val))->from($table)->execute();
     return !($result->count() > 0);
     Validation::active()->set_message('unique', 'The field :label must be unique, but :value has already been used');
 }
Example #2
0
 /**
  * A validation function which checks if the number passed 
  * to it is a valid location ID.
  * @param type $val
  * @return boolean
  */
 public static function _validation_valid_location($val)
 {
     if (Model_Orm_Location::find($val) == null) {
         Validation::active()->set_message('valid_location', 'The field "location" must refer to a valid location.');
         return false;
     }
     return true;
 }
Example #3
0
 /**
  * validate no space between text.
  *
  * @param mixed $val
  * @return boolean
  */
 public function _validation_noSpaceBetweenText($val)
 {
     \Validation::active()->set_message('noSpaceBetweenText', __('account_invalid_space_between_text'));
     if (preg_match('/\\s/', $val) == false) {
         // not found space, return true.
         return true;
     } else {
         // found space, return false.
         return false;
     }
 }
Example #4
0
 public static function _validation_current_password($val, $options)
 {
     $encode_password = \Auth::hash_password($val);
     $arrOption = explode('.', $options);
     $table = $arrOption[0];
     $pk = $arrOption[1];
     $field = $arrOption[2];
     $id = isset($arrOption[3]) ? $arrOption[3] : '';
     $result = DB::select("LOWER (\"{$field}\"), {$pk}")->where($pk, '=', $id)->and_where($field, '=', $encode_password)->from($table)->execute()->current();
     Validation::active()->set_message('current_password', 'パスワードが異なります。');
     return !empty($result) ? true : false;
 }
 /**
  * Check if a value is unique in column
  *
  * @param   string   $val
  * @param   array    $options   keys are 0:table, 1:field, 2:id field value, 3:id field. Default id field is id
  */
 public function _validation_unique($val, $options = array())
 {
     Validation::active()->set_message('unique', 'It appears you have already registered using this email address.');
     $result = \DB::select("LOWER (\"{$options['1']}\")")->from($options['0'])->where($options['1'], '=', Str::lower($val));
     if (!empty($options['2']) && is_numeric($options['2'])) {
         $id = empty($options['3']) ? 'id' : $options['3'];
         $result->where($id, '!=', $options['2']);
     }
     if (count($result->execute()) > 0) {
         return false;
     } else {
         return true;
     }
 }
Example #6
0
 /**
  * Validate number of product in one row
  *
  * @return boolean result of validation
  *
  * @since 1.0
  * @version 1.0
  * @access public
  * @author Dao Anh Minh
  */
 public static function _validation_sanpham_number($number)
 {
     Validation::active()->set_message('sanpham_number', 'Chỉ chấp nhận hiển thị 3 hoặc 4 sản phẩm trong 1 dòng');
     return $number == 3 or $number == 4;
 }
Example #7
0
File: rules.php Project: xXLXx/ddc
 public static function _validation_date_greater($val, $table_field)
 {
     Validation::active()->set_message('date_greater', ':label should be greater than ' . Validation::active()->field($table_field)->label . '.');
     return !Validation::active()->input($table_field) || !$val || $val > Validation::active()->input($table_field);
 }
Example #8
0
 /**
  * Required but not zero
  *
  * Value may not be empty
  *
  * @param   mixed
  * @return  bool
  */
 public function _validation_required_not_zero($val)
 {
     Validation::active()->set_message('required_not_zero', 'The field :label is required and must contain a value.');
     return !($this->_empty($val) || $val == '0');
 }