tartan / laravel-custom-validator
Laravel 5+ custom validators
5.0.0
2018-05-19 12:44 UTC
Requires
- php: >=5.4.0
- illuminate/support: >=5.0.0
Requires (Dev)
- phpunit/phpunit: >=4.0
This package is auto-updated.
Last update: 2024-11-27 07:59:17 UTC
README
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.
Support This Project
License
The Laravel Custom Validator is open-sourced software licensed under the MIT license