当前位置: 首页>>代码示例>>PHP>>正文


PHP Validator::replacer方法代码示例

本文整理汇总了PHP中Illuminate\Support\Facades\Validator::replacer方法的典型用法代码示例。如果您正苦于以下问题:PHP Validator::replacer方法的具体用法?PHP Validator::replacer怎么用?PHP Validator::replacer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Illuminate\Support\Facades\Validator的用法示例。


在下文中一共展示了Validator::replacer方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: registerValidators

 private function registerValidators()
 {
     Validator::extend('extensions', function ($attribute, $value, $parameters) {
         return in_array($value->getClientOriginalExtension(), $parameters);
     });
     Validator::replacer('extensions', function ($message, $attribute, $rule, $parameters) {
         return str_replace([':attribute', ':values'], [$attribute, implode(',', $parameters)], $message);
     });
 }
开发者ID:psybaron,项目名称:Translation,代码行数:9,代码来源:TranslationServiceProvider.php

示例2: boot

 /**
  * Bootstrap any application services.
  *
  * @return void
  */
 public function boot()
 {
     Validator::extend('greater_than_field', function ($attribute, $value, $parameters, $validator) {
         $min_field = $parameters[0];
         $data = $validator->getData();
         $min_value = $data[$min_field];
         return $value >= $min_value;
     });
     Validator::replacer('greater_than_field', function ($message, $attribute, $rule, $parameters) {
         return str_replace(':field', $parameters[0], "Max cannot be less than min");
     });
 }
开发者ID:apatel23,项目名称:CSCI445_final_project_12_6,代码行数:17,代码来源:AppServiceProvider.php

示例3: boot

 /**
  * Bootstrap any application services.
  *
  * @return void
  */
 public function boot()
 {
     //
     Validator::extend('greater_than_field', function ($attribute, $value, $parameters, $validator) {
         $min_field = $parameters[0];
         $data = $validator->getData();
         $min_value = $data[$min_field];
         return $value > $min_value;
     });
     Validator::replacer('greater_than_field', function ($message, $attribute, $rule, $parameters) {
         return str_replace(':field', $parameters[0], "Check that min members per team is less than max members per team!");
     });
 }
开发者ID:nwinbush,项目名称:CSCI445FinalPro,代码行数:18,代码来源:AppServiceProvider.php

示例4: boot

 public function boot()
 {
     $this->loadTranslationsFrom(__DIR__ . '/lang', 'laravel-profane');
     $this->publishes([__DIR__ . '/lang' => resource_path('lang/vendor/laravel-profane')]);
     Validator::extend('profane', 'LaravelProfane\\ProfaneValidator@validate', Lang::get('laravel-profane::validation.profane'));
     Validator::replacer('profane', function ($message, $attribute, $rule, $parameters) {
         return str_replace(':attribute', $attribute, $message);
     });
 }
开发者ID:arandilopez,项目名称:laravel-profane,代码行数:9,代码来源:ProfaneServiceProvider.php

示例5: boot

 /**
  * Bootstrap the application services.
  *
  * @return void
  */
 public function boot()
 {
     Validator::extend('current_password', function ($attribute, $value, $parameters, $validator) {
         return Hash::check($value, Auth::user()->password);
     });
     Validator::replacer('current_password', function ($message, $attribute, $rule, $parameters) {
         return str_replace($message, $message, 'Incorrect current password.');
     });
 }
开发者ID:ALIKALANAD,项目名称:classifieds,代码行数:14,代码来源:ValidatorServiceProvider.php

示例6: boot

 public function boot()
 {
     Validator::extend('jalali', JalaliValidator::class . '@validateJalali');
     Validator::extend('jalali_after', JalaliValidator::class . '@validateAfter');
     Validator::extend('jalali_before', JalaliValidator::class . '@validateBefore');
     Validator::replacer('jalali', JalaliValidator::class . '@replaceJalali');
     Validator::replacer('jalali_after', JalaliValidator::class . '@replaceAfterOrBefore');
     Validator::replacer('jalali_before', JalaliValidator::class . '@replaceAfterOrBefore');
 }
开发者ID:halaei,项目名称:jalali,代码行数:9,代码来源:JalaliServiceProvider.php

示例7: registerJDateTimeRules

 protected function registerJDateTimeRules()
 {
     Validator::extend('jdatetime', JalaliValidator::class . '@validateJDateTime');
     Validator::extend('jdatetime_after', JalaliValidator::class . '@validateJDateTimeAfter');
     Validator::extend('jdatetime_before', JalaliValidator::class . '@validateJDateTimeBefore');
     Validator::replacer('jdatetime', JalaliValidator::class . '@replaceJalali');
     Validator::replacer('jdatetime_after', JalaliValidator::class . '@replaceAfterOrBefore');
     Validator::replacer('jdatetime_before', JalaliValidator::class . '@replaceAfterOrBefore');
 }
开发者ID:opilo,项目名称:farsi,代码行数:9,代码来源:FarsiServiceProvider.php

示例8: boot

 /**
  * Bootstrap the application services.
  *
  * @return void
  */
 public function boot()
 {
     Validator::extend('cnp', function ($attribute, $value, $parameters) {
         return Cnp::valid($value);
     });
     Validator::replacer('cnp', function ($message, $attribute, $rule, $parameters) {
         $message = "Cnp-ul introdus nu este corect!";
         return $message;
     });
 }
开发者ID:filipac,项目名称:cnp,代码行数:15,代码来源:CnpValidatorProvider.php

示例9: boot

 /**
  * Bootstrap the application services.
  *
  * @return void
  */
 public function boot()
 {
     $this->loadTranslationsFrom(__DIR__ . '/../../resources/lang', 'instance-validator');
     $this->publishes([__DIR__ . '/../../resources/lang' => resource_path('lang/vendor/instance-validator')]);
     Validator::extend('instance_of', function ($attribute, $value, $parameters, $validator) {
         if (count($parameters) != 1) {
             throw new Exception("The 'instance_of' validator requires a single type to be specified.");
         }
         return $value instanceof $parameters[0];
     });
     Validator::replacer('instance_of', function ($message, $attribute, $rule, $parameters) {
         $msg = Lang::trans('instance-validator::' . $message);
         $msg = str_replace([':attribute', ':type'], [$attribute, $parameters[0]], $msg);
         return $msg;
     });
     // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     Validator::extend('collection_of', function ($attribute, $value, $parameters, $validator) {
         if (count($parameters) != 1) {
             throw new Exception("The 'collection_of' validator requires a single type to be specified.");
         }
         $isCollection = $value instanceof Collection;
         $itemIsCorrectType = $value[0] instanceof $parameters[0] || strtolower($parameters[0]) === 'string' && is_string($value[0]);
         return $isCollection && $itemIsCorrectType;
     });
     Validator::replacer('collection_of', function ($message, $attribute, $rule, $parameters) {
         $msg = Lang::trans('instance-validator::' . $message);
         $msg = str_replace([':attribute', ':type'], [$attribute, $parameters[0]], $msg);
         return $msg;
     });
     // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     Validator::extend('paginator_of', function ($attribute, $value, $parameters, $validator) {
         if (count($parameters) != 1) {
             throw new Exception("The 'paginator_of' validator requires a single type to be specified.");
         }
         if (!$value instanceof LengthAwarePaginator) {
             throw new Exception("The 'paginator_of' validator requires a LengthAwarePaginator instance.");
         }
         $itemIsCorrectType = $value->items()[0] instanceof $parameters[0] || strtolower($parameters[0]) === 'string' && is_string($value->items()[0]);
         return $itemIsCorrectType;
     });
     Validator::replacer('paginator_of', function ($message, $attribute, $rule, $parameters) {
         $msg = Lang::trans('instance-validator::' . $message);
         $msg = str_replace([':attribute', ':type'], [$attribute, $parameters[0]], $msg);
         return $msg;
     });
 }
开发者ID:timmcleod,项目名称:laravel-instance-validator,代码行数:51,代码来源:InstanceValidatorServiceProvider.php

示例10: boot

 /**
  * Bootstrap any application services.
  *
  * @return void
  */
 public function boot()
 {
     Validator::extend('greater_than_field', function ($attribute, $value, $parameters, $validator) {
         $other = Input::get($parameters[0]);
         return isset($other) and intval($value) >= intval($other);
     });
     Validator::replacer('greater_than_field', function ($message, $attribute, $rule, $parameters) {
         return str_replace(':field', $parameters[0], $message);
     });
     Validator::extend('is_after_date', function ($attribute, $value, $parameters, $validator) {
         $other = Input::get($parameters[0]);
         return isset($other) and new DateTime($value) >= new DateTime($other);
     });
     Validator::replacer('is_after_date', function ($message, $attribute, $rule, $parameters) {
         return str_replace(':field', $parameters[0], $message);
     });
 }
开发者ID:matyapav,项目名称:sh-league,代码行数:22,代码来源:AppServiceProvider.php

示例11: boot

 /**
  * Bootstrap any application services.
  *
  * @return void
  */
 public function boot(Router $router)
 {
     if (!$this->app->routesAreCached()) {
         require __DIR__ . '/../Http/routes.php';
     }
     $router->middleware('admin', \Philsquare\LaraManager\Http\Middleware\AdminMiddleware::class);
     $router->middleware('guest.admin', \Philsquare\LaraManager\Http\Middleware\RedirectIfAuthenticated::class);
     $this->loadViewsFrom(__DIR__ . '/../../../views', 'laramanager');
     $this->assetsToPublish();
     $this->setViewComposers();
     $this->loadTranslationsFrom(__DIR__ . '/../../../lang', 'laramanager');
     Validator::extend('unique_filename', 'Philsquare\\LaraManager\\Validators\\UniqueFilenameValidator@validate');
     Validator::extend('model_must_exist', 'Philsquare\\LaraManager\\Validators\\ModelMustExistValidator@validate');
     Validator::replacer('model_must_exist', function ($message, $attribute, $rule, $parameters) {
         return trans('laramanager::validation.model_must_exist');
     });
 }
开发者ID:philsquare,项目名称:laramanager,代码行数:22,代码来源:LaraManagerServiceProvider.php

示例12: height

 protected function height()
 {
     $this->app->before(function () {
         Validator::extend('height', 'Moxar\\Validation\\Rules\\Image@height');
         Validator::replacer('height', function ($message, $attribute, $rule, $parameters) {
             return $message = str_replace(':value', $parameters[0], $message);
         });
     });
 }
开发者ID:moxar,项目名称:validation,代码行数:9,代码来源:ValidationServiceProvider.php

示例13: extendValidator

 /**
  * add custom validation rules
  */
 protected function extendValidator()
 {
     Validator::extend('gt', function ($attribute, $value, $parameters, $validator) {
         return $value > $parameters[0];
     });
     Validator::extend('gte', function ($attribute, $value, $parameters, $validator) {
         return $value >= $parameters[0];
     });
     Validator::extend('lt', function ($attribute, $value, $parameters, $validator) {
         return $value < $parameters[0];
     });
     Validator::extend('lte', function ($attribute, $value, $parameters, $validator) {
         return $value <= $parameters[0];
     });
     Validator::replacer('gt', function ($message, $attribute, $rule, $parameters) {
         return str_replace([':attribute', ':gt'], [$attribute, $parameters[0]], $message);
     });
     Validator::replacer('gte', function ($message, $attribute, $rule, $parameters) {
         return str_replace([':attribute', ':gte'], [$attribute, $parameters[0]], $message);
     });
     Validator::replacer('lt', function ($message, $attribute, $rule, $parameters) {
         return str_replace([':attribute', ':lt'], [$attribute, $parameters[0]], $message);
     });
     Validator::replacer('lte', function ($message, $attribute, $rule, $parameters) {
         return str_replace([':attribute', ':lte'], [$attribute, $parameters[0]], $message);
     });
 }
开发者ID:trungtnm,项目名称:backend,代码行数:30,代码来源:TrungtnmBackendServiceProvider.php

示例14: function

Validator::replacer('positive', function ($message, $attribute, $rule, $parameters) {
    return sprintf('The %s must contain a positive number', $attribute);
});
/*
 * Validates the submitted value if it is greater than the validation parameter.
 */
Validator::extend('greater_than', 'Stevebauman\\Maintenance\\Validators\\GreaterThanNumberValidator@validateGreaterThan');
Validator::replacer('greater_than', function ($message, $attribute, $rule, $parameters) {
    return sprintf('The %s must be greater than %s', $attribute, $parameters[0]);
});
/*
 * Validates the submitted value if its less than the validation parameter.
 */
Validator::extend('less_than', 'Stevebauman\\Maintenance\\Validators\\LessThanNumberValidator@validateLessThan');
Validator::replacer('less_than', function ($message, $attribute, $rule, $parameters) {
    return sprintf('The %s must be less than %s', $attribute, $parameters[0]);
});
/*
 * Validates that the current user only has one session open
 */
Validator::extend('session_start', 'Stevebauman\\Maintenance\\Validators\\WorkOrder\\SessionStartValidator@validateSessionStart');
Validator::replacer('session_start', function () {
    return "You already have an open session, you must close it to begin a new one.";
});
/*
 * Validates that the current user can only close their session once
 */
Validator::extend('session_end', 'Stevebauman\\Maintenance\\Validators\\WorkOrder\\SessionEndValidator@validateSessionEnd');
Validator::replacer('session_end', function () {
    return "This session has already ended. You must create a new session.";
});
开发者ID:redknitin,项目名称:maintenance,代码行数:31,代码来源:validators.php


注:本文中的Illuminate\Support\Facades\Validator::replacer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。