1. Go to this page and download the library: Download kartik-v/yii2-validators library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
kartik-v / yii2-validators example snippets
use yii\db\ActiveRecord;
class EmailModel extends ActiveRecord {
/**
* @return array the validation rules.
*/
public function rules()
{
return [
[['to', 'cc', 'bcc'], 'k-email', 'allowName' => true, 'enableIDN' => true, 'max' => 5],
];
}
}
use yii\db\ActiveRecord;
class ContactModel extends ActiveRecord {
/**
* @return array the validation rules.
*/
public function rules()
{
return [
[['phone1'], 'k-phone', 'countryValue' => 'US'],
[['phone2'], 'k-phone', 'countryAttribute' => 'country', 'applyFormat' => false],
];
}
}
use yii\db\ActiveRecord;
class PaymentModel extends ActiveRecord {
/**
* @return array the validation rules.
*/
public function rules()
{
return [
[
['card_number'],
'k-card',
'typeAttribute' => 'card_type',
'holderAttribute' => 'holderName',
'expiryYearAttribute' => 'expiryYear',
'expiryMonthAttribute' => 'expiryMonth',
'cvvAttribute' => 'cvv',
],
];
}
}
use yii\db\ActiveRecord;
class ProductModel extends ActiveRecord {
/**
* @return array the validation rules.
*/
public function rules()
{
return [
[
['products_list_json'],
'k-json',
'prettify' => true, // set this to false if you do not wish to prettify the json input
],
];
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.