php yii-validators-ValidationAsset类(方法)实例源码

下面列出了php yii-validators-ValidationAsset 类(方法)源码代码实例,从而了解它的用法。

作者:kilyano    项目:yii   
/**
  * @inheritdoc
  */
 public function clientValidateAttribute($model, $attribute, $view)
 {
     if ($this->filter !== 'trim') {
         return null;
     }
     ValidationAsset::register($view);
     $options = $this->getClientOptions($model, $attribute);
     return 'value = yii.validation.trim($form, attribute, ' . json_encode($options, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) . ');';
 }

作者:Jaaviiee    项目:PrograWe   
/**
  * @inheritdoc
  */
 public function clientValidateAttribute($model, $attribute, $view)
 {
     $pattern = Html::escapeJsRegularExpression($this->pattern);
     $options = ['pattern' => new JsExpression($pattern), 'not' => $this->not, 'message' => Yii::$app->getI18n()->format($this->message, ['attribute' => $model->getAttributeLabel($attribute)], Yii::$app->language)];
     if ($this->skipOnEmpty) {
         $options['skipOnEmpty'] = 1;
     }
     ValidationAsset::register($view);
     return 'yii.validation.regularExpression(value, messages, ' . Json::htmlEncode($options) . ');';
 }

作者:farysht    项目:yii2-enu   
/**
  * @inheritdoc
  */
 public function clientValidateAttribute($model, $attribute, $view)
 {
     $this->ensureEnum($model, $attribute);
     $options = ['range' => array_map('strval', array_keys($this->enum)), 'not' => false, 'message' => Yii::$app->getI18n()->format($this->message, ['attribute' => $model->getAttributeLabel($attribute)], Yii::$app->language)];
     if ($this->skipOnEmpty) {
         $options['skipOnEmpty'] = 1;
     }
     ValidationAsset::register($view);
     return 'yii.validation.range(value, messages, ' . json_encode($options, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) . ');';
 }

作者:tsyry    项目:mybrio   
public function clientValidateAttribute($object, $attribute, $view)
 {
     $captcha = $this->createCaptchaAction();
     $code = $captcha->getVerifyCode(false);
     $hash = $captcha->generateValidationHash($this->caseSensitive ? $code : mb_strtolower($code));
     $options = ['hash' => $hash, 'hashKey' => 'yiiCaptcha/' . $this->captchaAction, 'caseSensitive' => $this->caseSensitive, 'message' => Yii::$app->getI18n()->format($this->message, ['attribute' => $object->getAttributeLabel($attribute)], Yii::$app->language)];
     if ($this->skipOnEmpty) {
         $options['skipOnEmpty'] = 1;
     }
     ValidationAsset::register($view);
     return 'yii.validation.captcha(value, messages, ' . json_encode($options, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) . ');';
 }

作者:sadiqhiran    项目:yii   
/**
  * @inheritdoc
  */
 public function clientValidateAttribute($model, $attribute, $view)
 {
     $options = ['trueValue' => $this->trueValue, 'falseValue' => $this->falseValue, 'message' => Yii::$app->getI18n()->format($this->message, ['attribute' => $model->getAttributeLabel($attribute), 'true' => $this->trueValue === true ? 'true' : $this->trueValue, 'false' => $this->falseValue === false ? 'false' : $this->falseValue], Yii::$app->language)];
     if ($this->skipOnEmpty) {
         $options['skipOnEmpty'] = 1;
     }
     if ($this->strict) {
         $options['strict'] = 1;
     }
     ValidationAsset::register($view);
     return 'yii.validation.boolean(value, messages, ' . json_encode($options, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) . ');';
 }

作者:dw25010078    项目:lulucm   
/**
  * @inheritdoc
  */
 public function clientValidateAttribute($object, $attribute, $view)
 {
     $options = ['trueValue' => $this->trueValue, 'falseValue' => $this->falseValue, 'message' => Yii::$app->getI18n()->format($this->message, ['attribute' => $object->getAttributeLabel($attribute), 'true' => $this->trueValue, 'false' => $this->falseValue], Yii::$app->language)];
     if ($this->skipOnEmpty) {
         $options['skipOnEmpty'] = 1;
     }
     if ($this->strict) {
         $options['strict'] = 1;
     }
     ValidationAsset::register($view);
     return 'yii.validation.boolean(value, messages, ' . json_encode($options) . ');';
 }

作者:hucongyan    项目:lulucms   
/**
  * @inheritdoc
  */
 public function clientValidateAttribute($model, $attribute, $view)
 {
     if ($this->filter !== 'trim') {
         return null;
     }
     $options = [];
     if ($this->skipOnEmpty) {
         $options['skipOnEmpty'] = 1;
     }
     ValidationAsset::register($view);
     return 'yii.validation.trim($form, attribute, ' . json_encode($options, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) . ');';
 }

作者:yuexiaoyu    项目:lulucm   
/**
  * @inheritdoc
  */
 public function clientValidateAttribute($object, $attribute, $view)
 {
     $range = [];
     foreach ($this->range as $value) {
         $range[] = (string) $value;
     }
     $options = ['range' => $range, 'not' => $this->not, 'message' => Yii::$app->getI18n()->format($this->message, ['attribute' => $object->getAttributeLabel($attribute)], Yii::$app->language)];
     if ($this->skipOnEmpty) {
         $options['skipOnEmpty'] = 1;
     }
     ValidationAsset::register($view);
     return 'yii.validation.range(value, messages, ' . json_encode($options) . ');';
 }

作者:kaliba    项目:magesk   
/**
  * @inheritdoc
  */
 public function clientValidateAttribute($model, $attribute, $view)
 {
     $options = ['operator' => $this->operator, 'type' => $this->type];
     if ($this->compareValue !== null) {
         $options['compareValue'] = $this->compareValue;
         $compareValue = $this->compareValue;
     } else {
         $compareAttribute = $this->compareAttribute === null ? $attribute . '_repeat' : $this->compareAttribute;
         $compareValue = $model->getAttributeLabel($compareAttribute);
         $options['compareAttribute'] = Html::getInputId($model, $compareAttribute);
     }
     if ($this->skipOnEmpty) {
         $options['skipOnEmpty'] = 1;
     }
     $options['message'] = Yii::$app->getI18n()->format($this->message, ['attribute' => $model->getAttributeLabel($attribute), 'compareAttribute' => $compareValue, 'compareValue' => $compareValue], Yii::$app->language);
     ValidationAsset::register($view);
     return 'yii.validation.compare(attribute, value, messages, ' . json_encode($options, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) . ');';
 }

作者:gerpay    项目:yii2-uedito   
/**
  * @inheritdoc
  */
 public function clientValidateAttribute($model, $attribute, $view)
 {
     $options = [];
     if ($this->requiredValue !== null) {
         $options['message'] = Yii::$app->getI18n()->format($this->message, ['requiredValue' => $this->requiredValue], Yii::$app->language);
         $options['requiredValue'] = $this->requiredValue;
     } else {
         $options['message'] = $this->message;
     }
     if ($this->strict) {
         $options['strict'] = 1;
     }
     $options['message'] = Yii::$app->getI18n()->format($options['message'], ['attribute' => $model->getAttributeLabel($attribute)], Yii::$app->language);
     ValidationAsset::register($view);
     $id = Html::getInputId($model, $attribute);
     // TODO require validation
     return '
     yii.validation.required(UE.getEditor("' . $id . '").getContent(), messages, ' . json_encode($options, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) . ');';
 }

作者:rajanishtime    项目:basicyi   
/**
  * @inheritdoc
  */
 public function clientValidateAttribute($object, $attribute, $view)
 {
     $pattern = $this->pattern;
     //$pattern = preg_replace('/\\\\x\{?([0-9a-fA-F]+)\}?/', '\u$1', $pattern);
     $deliminator = substr($pattern, 0, 1);
     $pos = strrpos($pattern, $deliminator, 1);
     $flag = substr($pattern, $pos + 1);
     if ($deliminator !== '/') {
         $pattern = '/' . str_replace('/', '\\/', substr($pattern, 1, $pos - 1)) . '/';
     } else {
         $pattern = substr($pattern, 0, $pos + 1);
     }
     if (!empty($flag)) {
         $pattern .= preg_replace('/[^igm]/', '', $flag);
     }
     $options = ['pattern' => new JsExpression($pattern), 'not' => $this->not, 'message' => Yii::$app->getI18n()->format($this->message, ['attribute' => $object->getAttributeLabel($attribute)], Yii::$app->language)];
     if ($this->skipOnEmpty) {
         $options['skipOnEmpty'] = 1;
     }
     ValidationAsset::register($view);
     return 'yii.validation.regularExpression(value, messages, ' . Json::encode($options) . ');';
 }

作者:indicalab    项目:yii2-phon   
public function clientValidateAttribute($model, $attribute, $view)
    {
        $className = explode('\\', $model->className());
        $className = strtolower(end($className));
        $formName = strtolower($model->formName());
        $label = $model->getAttributeLabel($attribute);
        $options = ['message' => Yii::$app->getI18n()->format($this->message, ['attribute' => $label], Yii::$app->language)];
        $formName = strtolower($model->formName());
        $options = Json::htmlEncode($options);
        ValidationAsset::register($view);
        $view->registerJs(<<<JS
(function(){\t\t\t\t
var telInput = \$("#{$formName}-{$attribute}");
if (!telInput.intlTelInput('isValidNumber')) {
\tmessages.push({$options}.message);
}
\t\tvar intlNumber = telInput.intlTelInput("getNumber");
\t\ttelInput.value = intlNumber;
\t\t
\t\tdocument.getElementById("{$className}-{$attribute}").value = intlNumber;
 \t\tdocument.getElementById("{$className}-{$attribute}").disabled = false;
\t\t
\t\t//var countryData = \$.fn.intlTelInput.getCountryData();
\t\t//console.log(countryData);
})();
JS
, \yii\web\View::POS_LOAD);
        // 		$view->registerJs(<<<JS
        // (function(){
        //     var telInput = $('#$formName-$attribute');
        // 	if (!telInput.intlTelInput('isValidNumber')) {
        // 	messages.push($options.message);
        // 		   }
        // })();
        // JS
        // 		, \yii\web\View::POS_LOAD);
    }

作者:Jaaviiee    项目:PrograWe   
/**
  * @inheritdoc
  */
 public function clientValidateAttribute($model, $attribute, $view)
 {
     ValidationAsset::register($view);
     $options = $this->getClientOptions($model, $attribute);
     return 'yii.validation.image(attribute, messages, ' . json_encode($options, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) . ', deferred);';
 }

作者:arogache    项目:yii   
/**
  * @inheritdoc
  */
 public function clientValidateAttribute($model, $attribute, $view)
 {
     $options = ['pattern' => new JsExpression($this->pattern), 'fullPattern' => new JsExpression($this->fullPattern), 'allowName' => $this->allowName, 'message' => Yii::$app->getI18n()->format($this->message, ['attribute' => $model->getAttributeLabel($attribute)], Yii::$app->language), 'enableIDN' => (bool) $this->enableIDN];
     if ($this->skipOnEmpty) {
         $options['skipOnEmpty'] = 1;
     }
     ValidationAsset::register($view);
     if ($this->enableIDN) {
         PunycodeAsset::register($view);
     }
     return 'yii.validation.email(value, messages, ' . Json::htmlEncode($options) . ');';
 }

作者:yiisof    项目:yii   
/**
  * @inheritdoc
  */
 public function clientValidateAttribute($model, $attribute, $view)
 {
     $messages = ['ipv6NotAllowed' => $this->ipv6NotAllowed, 'ipv4NotAllowed' => $this->ipv4NotAllowed, 'message' => $this->message, 'noSubnet' => $this->noSubnet, 'hasSubnet' => $this->hasSubnet];
     foreach ($messages as &$message) {
         $message = Yii::$app->getI18n()->format($message, ['attribute' => $model->getAttributeLabel($attribute)], Yii::$app->language);
     }
     $options = ['ipv4Pattern' => new JsExpression(Html::escapeJsRegularExpression($this->ipv4Pattern)), 'ipv6Pattern' => new JsExpression(Html::escapeJsRegularExpression($this->ipv6Pattern)), 'messages' => $messages, 'ipv4' => (bool) $this->ipv4, 'ipv6' => (bool) $this->ipv6, 'ipParsePattern' => new JsExpression(Html::escapeJsRegularExpression($this->getIpParsePattern())), 'negation' => $this->negation, 'subnet' => $this->subnet];
     if ($this->skipOnEmpty) {
         $options['skipOnEmpty'] = 1;
     }
     ValidationAsset::register($view);
     return 'yii.validation.ip(value, messages, ' . Json::htmlEncode($options) . ');';
 }

作者:ranmoo    项目:yii   
/**
  * @inheritdoc
  */
 public function clientValidateAttribute($model, $attribute, $view)
 {
     if ($this->range instanceof \Closure) {
         $this->range = call_user_func($this->range, $model, $attribute);
     }
     $range = [];
     foreach ($this->range as $value) {
         $range[] = (string) $value;
     }
     $options = ['range' => $range, 'not' => $this->not, 'message' => Yii::$app->getI18n()->format($this->message, ['attribute' => $model->getAttributeLabel($attribute)], Yii::$app->language)];
     if ($this->skipOnEmpty) {
         $options['skipOnEmpty'] = 1;
     }
     if ($this->allowArray) {
         $options['allowArray'] = 1;
     }
     ValidationAsset::register($view);
     return 'yii.validation.range(value, messages, ' . json_encode($options, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) . ');';
 }

作者:kilyano    项目:yii   
/**
  * @inheritdoc
  */
 public function clientValidateAttribute($model, $attribute, $view)
 {
     if ($this->range instanceof \Closure) {
         $this->range = call_user_func($this->range, $model, $attribute);
     }
     ValidationAsset::register($view);
     $options = $this->getClientOptions($model, $attribute);
     return 'yii.validation.range(value, messages, ' . json_encode($options, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) . ');';
 }

作者:kilyano    项目:yii   
/**
  * @inheritdoc
  */
 public function clientValidateAttribute($model, $attribute, $view)
 {
     ValidationAsset::register($view);
     if ($this->enableIDN) {
         PunycodeAsset::register($view);
     }
     $options = $this->getClientOptions($model, $attribute);
     return 'yii.validation.email(value, messages, ' . Json::htmlEncode($options) . ');';
 }

作者:aoopv    项目:EduSec4.0.   
/**
  * @inheritdoc
  */
 public function clientValidateAttribute($model, $attribute, $view)
 {
     if (strpos($this->pattern, '{schemes}') !== false) {
         $pattern = str_replace('{schemes}', '(' . implode('|', $this->validSchemes) . ')', $this->pattern);
     } else {
         $pattern = $this->pattern;
     }
     $options = ['pattern' => new JsExpression($pattern), 'message' => Yii::$app->getI18n()->format($this->message, ['attribute' => $model->getAttributeLabel($attribute)], Yii::$app->language), 'enableIDN' => (bool) $this->enableIDN];
     if ($this->skipOnEmpty) {
         $options['skipOnEmpty'] = 1;
     }
     if ($this->defaultScheme !== null) {
         $options['defaultScheme'] = $this->defaultScheme;
     }
     ValidationAsset::register($view);
     if ($this->enableIDN) {
         PunycodeAsset::register($view);
     }
     return 'yii.validation.url(value, messages, ' . Json::encode($options) . ');';
 }

作者:fangfac    项目:yii2-concor   
/**
  * @inheritdoc
  */
 public function clientValidateAttribute($model, $attribute, $view)
 {
     $options = [];
     if ($this->skipOnEmpty) {
         $options['skipOnEmpty'] = 1;
     }
     if ($this->stripSpaceBeforeComma) {
         $options['stripSpaceBeforeComma'] = 1;
     }
     if ($this->stripSpaceAfterComma) {
         $options['stripSpaceAfterComma'] = 1;
     }
     ValidationAsset::register($view);
     return 'value = localAppValidation.nocrlf($form, attribute, ' . json_encode($options, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) . ');';
 }


问题


面经


文章

微信
公众号

扫码关注公众号