Looking to hire Laravel developers? Try LaraJobs

laravel-custom-validator maintained by tartan

Description
Laravel 5+ custom validators
Last update
2020/03/26 22:37 (dev-master)
License
Downloads
178

Comments
comments powered by Disqus

Laravel 5+ Custom Validators

Installation

composer require "tartan/laravel-custom-validator"

Tartan Custom Validators

Add the required validator(s) to boot method of app/Providers/AppServiceProvider.php

Validator::extend('strength', 'Tartan\Validators\CustomValidator@validateStrength');
Validator::extend('iran_billing_id', 'Tartan\Validators\CustomValidator@validateIranBillingId');
Validator::extend('iran_shetab_card', 'Tartan\Validators\CustomValidator@validateShetabCard');
Validator::extend('uuid', 'Tartan\Validators\CustomValidator@validateUuid');
Validator::extend('iran_national_id', 'Tartan\Validators\CustomValidator@validateNationalId');

Add following lines to resources/lang/en/validation.php in Custom Validation Language Lines part

'strength' => 'The password :attribute is too weak and must contain one or more uppercase, lowercase, numeric, and special character (!@#$%^&*).',
'iran_billing_id' => 'The billing Id `:attribute` is not a valid Billing Id.',
'shetab_card' => 'The card number `:attribute` is not a valid Shetab card number.',
'uuid' => 'The UUID `:attribute` is not a valid UUID.',
'iran_national_id' => 'The national id `:attribute` is not a valid Iran nationa Id.',

Use like other validator

	...
	'national_id'    => 'required|iran_national_id|unique:users,national_id',
	'password'       => 'required|string|strength|min:6'
	...

Team

This component is developed by the following person(s) and a bunch of awesome contributors.

Aboozar Ghaffari
Aboozar Ghaffari

Support This Project

Donate via Paypal

License

The Laravel Custom Validator is open-sourced software licensed under the MIT license