Skip to content
This repository has been archived by the owner on Jul 10, 2021. It is now read-only.

Commit

Permalink
Merge pull request #44 from anetwork/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
shahrokhniakan authored Apr 18, 2017
2 parents a8dc9f1 + 7e00c3d commit 2949d09
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 18 deletions.
4 changes: 4 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -194,3 +194,7 @@ Validator::make( $request->all(), [

]);
```

### vendor:publish
You can run vendor:publish command to have custom lang file of package on this path ( resources/lang/validation )

22 changes: 5 additions & 17 deletions src/PersianValidationServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Illuminate\Support\ServiceProvider;
use Validator;
use App;

/**
* @author Shahrokh Niakan <[email protected]>
Expand All @@ -20,103 +21,91 @@ class PersianValidationServiceProvider extends ServiceProvider
*/
public function boot()
{
// publish lang file to resources/lang/validation
$this->publishes([
__DIR__.'/../lang/' . App::getLocale() . '.php' => resource_path( 'lang/validation/' . App::getLocale() . '.php' ),
]);

// create custom rule for Alpha
Validator::extend('persian_alpha', 'ValidationRules@Alpha');
// create custom message for Alpha
Validator::replacer('persian_alpha', 'ValidationMessages@AlphaMsg');


// create custom rule for Num
Validator::extend('persian_num', 'ValidationRules@Num');
// create custom message for Num
Validator::replacer('persian_num', 'ValidationMessages@NumMsg');


// create custom rule for AlphaNum
Validator::extend('persian_alpha_num', 'ValidationRules@AlphaNum');
// create custom message for AlphaNum
Validator::replacer('persian_alpha_num', 'ValidationMessages@AlphaNumMsg');


// create custom rule for IranMobile
Validator::extend('iran_mobile', 'ValidationRules@IranMobile');
// create custom message for IranMobile
Validator::replacer('iran_mobile', 'ValidationMessages@IranMobileMsg');


// create custom rule for Sheba
Validator::extend('sheba', 'ValidationRules@Sheba');
// create custom message for Sheba
Validator::replacer('sheba', 'ValidationMessages@ShebaMsg');


// create custom rule for MelliCode
Validator::extend('melli_code', 'ValidationRules@MelliCode');
// create custom message for MelliCode
Validator::replacer('melli_code', 'ValidationMessages@MelliCodeMsg');


// create custom rule for IsNotPersian
Validator::extend('is_not_persian', 'ValidationRules@IsNotPersian');
// create custom message for IsNotPersian
Validator::replacer('is_not_persian', 'ValidationMessages@IsNotPersianMsg');


// create custom rule for LimitArray
Validator::extend('limited_array', 'ValidationRules@LimitedArray');
// create custom message for LimitArray
Validator::replacer('limited_array', 'ValidationMessages@LimitedArrayMsg');


// create custom rule for UnSignedNum
Validator::extend('unsigned_num', 'ValidationRules@UnSignedNum');
// create custom message for UnSignedNum
Validator::replacer('unsigned_num', 'ValidationMessages@UnSignedNumMsg');


// create custom rule for AlphaSpace
Validator::extend('alpha_space', 'ValidationRules@AlphaSpace');
// create custom message for AlphaSpace
Validator::replacer('alpha_space', 'ValidationMessages@AlphaSpaceMsg');


// create custom rule for Url
Validator::extend('a_url', 'ValidationRules@Url');
// create custom message for Url
Validator::replacer('a_url', 'ValidationMessages@UrlMsg');


// create custom rule for Domain
Validator::extend('a_domain', 'ValidationRules@Domain');
// create custom message for Domain
Validator::replacer('a_domain', 'ValidationMessages@DomainMsg');


// create custom rule for More
Validator::extend('more', 'ValidationRules@More');
// create custom message for More
Validator::replacer('more', 'ValidationMessages@MoreMsg');


// create custom rule for Less
Validator::extend('less', 'ValidationRules@Less');
// create custom message for Less
Validator::replacer('less', 'ValidationMessages@LessMsg');


// create custom rule for IranPhone
Validator::extend('iran_phone', 'ValidationRules@IranPhone');
// create custom message for IranPhone
Validator::replacer('iran_phone', 'ValidationMessages@IranPhoneMsg');


// create custom rule for CardNumber
Validator::extend('card_number', 'ValidationRules@CardNumber');
// create custom message for CardNumber
Validator::replacer('card_number', 'ValidationMessages@CardNumberMsg');


// create custom rule for Address
Validator::extend('address', 'ValidationRules@Address');
// create custom message for Address
Expand All @@ -137,7 +126,6 @@ public function boot()
*/
public function register()
{

$this->app->bind('ValidationRules', 'Anetwork\Validation\ValidationRules');

$this->app->bind('ValidationMessages', 'Anetwork\Validation\ValidationMessages');
Expand Down
6 changes: 5 additions & 1 deletion src/ValidationMessages.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ public function __construct() {

$this->lang = \App::getLocale();

$this->config = include __DIR__ . '/../lang/' . $this->lang . '.php';
if(! file_exists(resource_path('lang/validation/' . $this->lang . '.php'))){
$this->config = include __DIR__ . '/../lang/' . $this->lang . '.php';
} else {
$this->config = include resource_path('lang/validation/' . $this->lang . '.php');
}

}

Expand Down

0 comments on commit 2949d09

Please sign in to comment.