Author: HimikLab
Inheritance: extends yii\validators\Validator
Esempio n. 1
0
 public function rules()
 {
     $rules = [[['screen_name', 'password', 'password_repeat'], 'required'], [['screen_name'], 'string', 'max' => 15], [['screen_name'], 'match', 'pattern' => '/^[a-zA-Z0-9_]{1,15}$/', 'message' => '{attribute} must be at most 15 alphanumeric or underscore characters.'], [['screen_name'], 'unique', 'targetClass' => User::className(), 'message' => Yii::t('app', 'This {attribute} is already in use.')], [['name'], 'string', 'max' => 15], [['password_repeat'], 'compare', 'compareAttribute' => 'password', 'operator' => '===']];
     if (Yii::$app->params['googleRecaptcha']['siteKey'] != '') {
         $rules[] = [['recaptcha_token', 'recaptcha_response'], 'required', 'message' => Yii::t('app', 'Please check the reCAPTCHA.')];
         $rules[] = [[], ReCaptchaValidator::className(), 'secret' => Yii::$app->params['googleRecaptcha']['secret']];
     }
     return $rules;
 }
 /**
  * @inheritdoc
  */
 public function rules()
 {
     $captcha = [];
     if (Core::isReCaptchaEnabled()) {
         $captcha = [['verifyCode', 'required', 'message' => Yii::t('app', 'Prove you are NOT a robot')], ['verifyCode', ReCaptchaValidator::className(), 'message' => Yii::t('app', 'Prove you are NOT a robot')]];
     }
     $default = [[['newEmail'], 'required'], ['newEmail', 'email'], ['newEmail', 'filter', 'filter' => 'trim'], ['newEmail', 'filter', 'filter' => 'strtolower'], ['newEmail', 'unique', 'targetAttribute' => 'email', 'targetClass' => 'common\\models\\Account', 'message' => Yii::t('app', 'This email address has already been taken.')]];
     return array_merge($default, $captcha);
 }
Esempio n. 3
0
 public function rules()
 {
     $rules = [[['screen_name', 'password'], 'required'], [['screen_name'], 'string', 'max' => 15], [['screen_name'], 'match', 'pattern' => '/^[a-zA-Z0-9_]{1,15}$/', 'message' => 'ログイン名は英数とアンダーバーの15文字以内で決めてください'], [['screen_name'], 'unique', 'targetClass' => User::className(), 'message' => 'このログイン名は既に使用されています'], [['name'], 'string', 'max' => 15]];
     if (Yii::$app->params['googleRecaptcha']['siteKey'] != '') {
         $rules[] = [['recaptcha_token', 'recaptcha_response'], 'required', 'message' => 'reCAPTCHAの確認をしてください'];
         $rules[] = [[], ReCaptchaValidator::className(), 'secret' => Yii::$app->params['googleRecaptcha']['secret']];
     }
     return $rules;
 }
 /**
  * @inheritdoc
  */
 public function rules()
 {
     $captcha = [];
     if (Core::isReCaptchaEnabled()) {
         $captcha = [['verifyCode', 'required', 'message' => Yii::t('app', 'Prove you are NOT a robot')], ['verifyCode', ReCaptchaValidator::className(), 'message' => Yii::t('app', 'Prove you are NOT a robot')]];
     }
     $default = [['email', 'filter', 'filter' => 'trim'], ['email', 'filter', 'filter' => 'strtolower'], ['email', 'required'], ['email', 'email'], ['email', 'exist', 'targetClass' => 'common\\models\\Account', 'filter' => ['status' => Account::STATUS_ACTIVE], 'message' => Yii::t('app', 'There is no user with such email.')]];
     return array_merge($default, $captcha);
 }
Esempio n. 5
0
 /**
  * @return array the validation rules.
  */
 public function rules()
 {
     $rules = [[['name', 'email', 'subject', 'body'], 'required'], ['email', 'email']];
     // captcha
     $recaptchaSecret = env("RECAPTCHA_SECRET");
     if ($recaptchaSecret) {
         $rules[] = ['captcha', ReCaptchaValidator::className(), 'secret' => $recaptchaSecret, 'message' => Yii::t('app', 'Invalid captcha'), 'when' => function ($model) {
             return !$model->hasErrors();
         }];
     }
     return $rules;
 }
Esempio n. 6
0
 /**
  * @inheritdoc
  */
 public function rules()
 {
     return [[['name', 'email', 'subject', 'body'], 'required'], ['email', 'email'], [['verifyCode'], \himiklab\yii2\recaptcha\ReCaptchaValidator::className()]];
 }
Esempio n. 7
0
 /**
  * @inheritdoc
  */
 public function rules()
 {
     return [[['transaction_id', 'customer_name', 'customer_email', 'customer_phone_number', 'customer_country', 'delivery_to', 'captcha'], 'required'], [['language_id', 'status', 'customer_id', 'customer_phone_number', 'shipping_fee'], 'integer'], [['delivered_at', 'shipped_at'], 'safe'], [['transaction_id', 'customer_name', 'customer_email', 'customer_city', 'customer_country', 'shipping_via', 'payment_method'], 'string', 'max' => 255], [['customer_address', 'delivery_to', 'shipping_from'], 'string', 'max' => 511], [['country_calling_code', 'zip_postal_code'], 'string', 'max' => 25], [['customer_email'], 'email'], [['customer_note', 'user_note'], 'string', 'max' => 2000], [['transaction_id'], 'unique'], [['captcha'], ReCaptchaValidator::className(), 'secret' => '6Lc6DBkTAAAAAFsBDbc7tTosnHpy7DISPS8rqsZH']];
 }
Esempio n. 8
0
 /**
  * @inheritdoc
  */
 public function rules()
 {
     return [[['body', 'name', 'email'], 'required'], [['body', 'status'], 'string'], [['user_id', 'date'], 'integer'], [['ip'], 'string', 'max' => 50], [['name'], 'string', 'max' => 100], [['email'], 'string', 'max' => 255], ['email', 'email'], [['reCaptcha'], \himiklab\yii2\recaptcha\ReCaptchaValidator::className(), 'secret' => '6LedACkTAAAAAABRB94hv1GBWA3ZreeDbexv0aSY']];
 }
Esempio n. 9
0
 /**
  * @inheritdoc
  */
 public function rules()
 {
     return [[['username', 'auth_key', 'email', 'firstname', 'lastname', 'created_at', 'password'], 'required'], [['phone_number', 'gender', 'language_id', 'is_active', 'status', 'total_purchase_orders', 'total_purchase_products', 'total_purchase_value'], 'integer'], [['created_at', 'updated_at', 'dob'], 'safe'], [['username', 'password_hash', 'password_reset_token', 'email'], 'string', 'max' => 255], [['auth_key'], 'string', 'max' => 32], [['address', 'firstname', 'lastname', 'image', 'image_path'], 'string', 'max' => 511], [['zip_postal_code'], 'string', 'max' => 25], ['username', 'filter', 'filter' => 'trim'], ['email', 'filter', 'filter' => 'trim'], ['username', 'unique'], ['email', 'unique'], ['email', 'email'], [['password_reset_token'], 'unique'], [['password'], 'string', 'min' => 6, 'max' => 100, 'on' => 'create'], [['new_password'], 'string', 'min' => 6, 'max' => 100, 'on' => 'update'], ['confirm_password', 'compare', 'compareAttribute' => 'password', 'operator' => '==', 'message' => I18n::t('Password and confirm password do not match'), 'on' => 'create'], [['confirm_password', 'captcha'], 'required', 'on' => 'create'], ['confirm_new_password', 'compare', 'compareAttribute' => 'new_password', 'operator' => '==', 'message' => I18n::t('Password and confirm password do not match'), 'on' => 'update'], [['captcha'], ReCaptchaValidator::className(), 'secret' => '6Lc6DBkTAAAAAFsBDbc7tTosnHpy7DISPS8rqsZH']];
 }
Esempio n. 10
0
 /**
  * @inheritdoc
  */
 public function rules()
 {
     return [[['name', 'email', 'subject', 'body'], 'required'], ['email', 'email'], [[], ReCaptchaValidator::className()]];
 }
Esempio n. 11
0
 /**
  * @return array the validation rules.
  */
 public function rules()
 {
     return [[['policy', 'last_name'], 'required'], [['policy'], 'string', 'max' => 16], [['last_name'], 'string', 'max' => 64], ['captcha', ReCaptchaValidator::className(), 'secret' => '6LfPPBQTAAAAAKHaK89OA7SabTX8sFlvTZCSZaFO'], [['policy', 'last_name'], 'validatePatient']];
 }
Esempio n. 12
0
 /**
  * @inheritdoc
  */
 public function rules()
 {
     return [[['product_id', 'product_name', 'product_code', 'product_price', 'product_original_price', 'customer_name', 'customer_email', 'created_at', 'captcha'], 'required'], [['product_id', 'product_price', 'product_original_price', 'customer_id', 'customer_phone_number', 'language_id', 'noreply_email_id', 'status'], 'integer'], [['created_at', 'updated_at', 'replied_at'], 'safe'], [['product_name', 'customer_name', 'customer_email', 'updated_by', 'replied_by'], 'string', 'max' => 255], ['customer_email', 'email'], [['product_code', 'zip_postal_code'], 'string', 'max' => 25], [['product_id'], 'unique', 'targetAttribute' => ['product_id', 'customer_email', 'customer_phone_number', 'status'], 'message' => I18n::t('A product following already exists with the same information')], [['captcha'], ReCaptchaValidator::className(), 'secret' => '6Lc6DBkTAAAAAFsBDbc7tTosnHpy7DISPS8rqsZH']];
 }
Esempio n. 13
0
 public function rules()
 {
     return [["NOMBRE_USUARIO", "required", "message" => "Campo requerido."], ["NOMBRE_USUARIO", "string", "message" => "Debe de ser una cadena de texto"], ["NOMBRE_USUARIO", "unique", "on" => "insert", "message" => "Usuario ya existe"], ["NOMBRE_USUARIO", "match", "pattern" => "/^[a-záéíóúñ]+\$/i", "message" => "Solo se aceptan letras"], ["id_departamento", "integer", "message" => "Debe de ser un número"], ["id_rol", "required", "message" => "Campo requerido."], ["EMAIL", "required", "message" => "Campo requerido."], ["EMAIL", "email", "message" => "Debe ser un Email valido."], ["EMAIL", "unique", "on" => "insert", "message" => "Email ya registrado"], ["password", "required", "message" => "Campo requerido."], ["password", "string", "message" => "Debe ingresar una cadena de texto."], ["password_repeat", "required", "message" => "Campo requerido."], ["password_repeat", "compare", "compareAttribute" => "password", "message" => "No son iguales."], [['reCaptcha'], ReCaptchaValidator::className(), 'secret' => '6LfD6hITAAAAAEdV6MQ8zDX3emwQY4bVYyw-L3nz']];
 }
Esempio n. 14
0
 /**
  * @inheritdoc
  */
 public function rules()
 {
     return [[['title', 'body', 'status', 'blog_id'], 'required'], [['blog_id'], 'integer'], ['status', 'default', 'value' => self::STATUS_PENDING], ['status', 'in', 'range' => [self::STATUS_PENDING, self::STATUS_APPROVED, self::STATUS_REJECTED]], [['body'], 'string'], [['title'], 'string', 'max' => 255], [['reCaptcha'], \himiklab\yii2\recaptcha\ReCaptchaValidator::className(), 'skipOnEmpty' => !\yii::$app->user->isGuest]];
 }
Esempio n. 15
0
 public function rules()
 {
     return [[['username', 'password'], 'required'], ['rememberMe', 'boolean'], ['password', 'validatePassword'], [['reCaptcha'], \himiklab\yii2\recaptcha\ReCaptchaValidator::className(), 'secret' => '6LcWAxMTAAAAAEZCbXGi-azhHhA8kYRq5WmY9pLg', 'on' => 'loginWithCaptcha']];
 }
Esempio n. 16
0
 /**
  * @inheritdoc
  */
 public function rules()
 {
     return [['email', 'filter', 'filter' => 'trim'], [['email', 'captcha'], 'required'], ['email', 'email'], ['email', 'exist', 'targetClass' => '\\frontend\\models\\Customer', 'filter' => ['status' => Customer::STATUS_ACTIVE], 'message' => I18n::t('There is no user with such email')], [['captcha'], ReCaptchaValidator::className(), 'secret' => '6Lc6DBkTAAAAAFsBDbc7tTosnHpy7DISPS8rqsZH']];
 }
 /**
  * @inheritdoc
  */
 public function rules()
 {
     return [['username', 'filter', 'filter' => 'trim'], ['username', 'required'], ['username', 'unique', 'targetClass' => '\\common\\models\\User', 'message' => 'This username has already been taken.'], ['username', 'string', 'min' => 2, 'max' => 255], ['real_name', 'filter', 'filter' => 'trim'], ['real_name', 'required'], ['real_name', 'string', 'min' => 2, 'max' => 255], ['burn_name', 'filter', 'filter' => 'trim'], ['burn_name', 'string', 'min' => 2, 'max' => 255], ['email', 'filter', 'filter' => 'trim'], ['email', 'required'], ['email', 'email'], ['email', 'string', 'max' => 255], ['email', 'unique', 'targetClass' => '\\common\\models\\User', 'message' => 'This email address has already been taken.'], ['password', 'required'], ['password', 'string', 'min' => 6], [['reCaptcha'], \himiklab\yii2\recaptcha\ReCaptchaValidator::className()]];
 }
Esempio n. 18
0
 /**
  * @inheritdoc
  */
 public function rules()
 {
     return [[['nama', 'hp', 'angkatan'], 'required'], [['alamat'], 'string'], [['created'], 'safe'], [['nama'], 'string', 'max' => 200], [['hp', 'line'], 'string', 'max' => 20], [['bbm'], 'string', 'max' => 11], [['whatsapp'], 'string', 'max' => 15], [['angkatan'], 'string', 'max' => 4], [['reCaptcha'], ReCaptchaValidator::className()]];
 }
Esempio n. 19
0
 /**
  * @inheritdoc
  */
 public function rules()
 {
     return [[['post_id', 'author', 'message', 'dateadd'], 'required'], [['post_id', 'author', 'answer', 'status'], 'integer'], [['message'], 'string'], [['dateadd'], 'string', 'max' => 30], [['reCaptcha'], \himiklab\yii2\recaptcha\ReCaptchaValidator::className(), 'secret' => '6LcLNQUTAAAAAI5kJGhHKJ0DqVkosYjG_snBOY4S']];
 }
Esempio n. 20
0
 /**
  * @inheritdoc
  */
 public function rules()
 {
     $reCaptchaSecretKey = \Yii::$app->getModule('comment')->reCaptchaSecretKey;
     return [[['record_id', 'author'], 'required', 'on' => ['add-guest', 'add-user']], [['id', 'record_id', 'user_id', 'rating', 'created_at', 'parentId'], 'integer'], [['comment'], 'required', 'on' => ['add-guest', 'add-user'], 'message' => 'Comment can\'t be blank! It\'s like grog without rum!'], [['comment'], 'string'], [['author'], 'string', 'max' => 255], [['user_hash'], 'string', 'max' => 32], [['reCaptcha'], ReCaptchaValidator::className(), 'secret' => $reCaptchaSecretKey, 'on' => ['add-guest']]];
 }
Esempio n. 21
0
 public function rules()
 {
     return [["NOMBRE_DEPARTAMENTO", "required", "message" => "Ingrese nombre departamento"], ["NOMBRE_DEPARTAMENTO", "match", "pattern" => "/^[a-záéíóúñ]+\$/i", "message" => "Solo se aceptan letras"], ["NOMBRE_DEPARTAMENTO", "unique", "message" => "Departamento ya existe"], ["NOMBRE_DEPARTAMENTO", "string", "message" => "Debe de ser una cadena de texto"], [['reCaptcha'], ReCaptchaValidator::className(), 'secret' => '6LfD6hITAAAAAEdV6MQ8zDX3emwQY4bVYyw-L3nz']];
 }