PHP code example of arifszn / laravel-advanced-validation
1. Go to this page and download the library: Download arifszn/laravel-advanced-validation 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/ */
arifszn / laravel-advanced-validation example snippets
use Arifszn\AdvancedValidation\Rules\Username;
public function rules()
{
return [
'foo' => [new Username('Your custom error message')],
];
}
use Arifszn\AdvancedValidation\Rules\Ascii;
public function rules()
{
return [
'foo' => [new Ascii()],
];
}
use Arifszn\AdvancedValidation\Rules\Base64Image;
public function rules()
{
return [
'avatar' => [new Base64Image()],
];
}
use Arifszn\AdvancedValidation\Rules\Base64String;
public function rules()
{
return [
'foo' => [new Base64String()],
];
}
use Arifszn\AdvancedValidation\Rules\BIC;
public function rules()
{
return [
'foo' => [new BIC()],
];
}
use Arifszn\AdvancedValidation\Rules\BtcAddress;
public function rules()
{
return [
'foo' => [new BtcAddress()],
];
}
use Arifszn\AdvancedValidation\Rules\CreditCard;
public function rules()
{
return [
'foo' => [new CreditCard()],
];
}
use Arifszn\AdvancedValidation\Rules\DataURI;
public function rules()
{
return [
'foo' => [new DataURI()],
];
}
use Arifszn\AdvancedValidation\Rules\DivisibleBy;
public function rules()
{
return [
'foo' => [new DivisibleBy(2)],
];
}
use Arifszn\AdvancedValidation\Rules\EthereumAddress;
public function rules()
{
return [
'foo' => [new EthereumAddress()],
];
}
use Arifszn\AdvancedValidation\Rules\FloatNumber;
public function rules()
{
return [
'foo' => [new FloatNumber()],
];
}
use Arifszn\AdvancedValidation\Rules\Hash;
public function rules()
{
return [
'foo' => [new Hash('md4')],
];
}
use Arifszn\AdvancedValidation\Rules\ImageURL;
public function rules()
{
return [
'avatar' => [new ImageURL()],
];
}
use Arifszn\AdvancedValidation\Rules\Jwt;
public function rules()
{
return [
'foo' => [new Jwt()],
];
}
use Arifszn\AdvancedValidation\Rules\Name;
public function rules()
{
return [
'name' => [new Name()],
];
}
use Arifszn\AdvancedValidation\Rules\Phone;
public function rules()
{
return [
'foo' => [new Phone()],
];
}
use Arifszn\AdvancedValidation\Rules\Username;
public function rules()
{
return [
'username' => [new Username()],
];
}
use Arifszn\AdvancedValidation\Rules\WithoutSpaces;
public function rules()
{
return [
'foo' => [new WithoutSpaces()],
];
}
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Validator;
use Arifszn\AdvancedValidation\Rules\Phone;
class AppServiceProvider extends ServiceProvider
{
public function boot()
{
Validator::extend(
'phone',
'Arifszn\AdvancedValidation\Rules\Phone@passes',
(new Phone())->message()
);
}
}