本文整理汇总了PHP中Validation::active方法的典型用法代码示例。如果您正苦于以下问题:PHP Validation::active方法的具体用法?PHP Validation::active怎么用?PHP Validation::active使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Validation
的用法示例。
在下文中一共展示了Validation::active方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _validation_unique
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');
}
示例2: _validation_valid_location
/**
* 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;
}
示例3: _validation_noSpaceBetweenText
/**
* 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;
}
}
示例4: _validation_current_password
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;
}
示例5: _validation_unique
/**
* 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;
}
}
示例6: _validation_sanpham_number
/**
* 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;
}
示例7: _validation_date_greater
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);
}
示例8: _validation_required_not_zero
/**
* 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');
}