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


PHP Factory::replacer方法代码示例

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


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

示例1: setUp

 public function setUp()
 {
     parent::setUp();
     $this->translator = new Translator(new \Illuminate\Translation\FileLoader(new \Illuminate\Filesystem\Filesystem(), __DIR__ . '/../sample-lang'), 'en');
     $this->translator->setLocale('en');
     $this->factory = new Factory($this->translator);
     $validator = new JalaliValidator();
     $this->factory->extend('jalali', function ($attribute, $value, $parameter) use($validator) {
         return $validator->validateJalali($attribute, $value, $parameter);
     });
     $this->factory->extend('jalali_after', function ($attribute, $value, $parameter) use($validator) {
         return $validator->validateAfter($attribute, $value, $parameter);
     });
     $this->factory->extend('jalali_before', function ($attribute, $value, $parameter) use($validator) {
         return $validator->validateBefore($attribute, $value, $parameter);
     });
     $this->factory->replacer('jalali', function ($message, $attribute, $rule, $parameter) use($validator) {
         return $validator->replaceJalali($message, $attribute, $rule, $parameter);
     });
     $this->factory->replacer('jalali_after', function ($message, $attribute, $rule, $parameter) use($validator) {
         return $validator->replaceAfterOrBefore($message, $attribute, $rule, $parameter);
     });
     $this->factory->replacer('jalali_before', function ($message, $attribute, $rule, $parameter) use($validator) {
         return $validator->replaceAfterOrBefore($message, $attribute, $rule, $parameter);
     });
 }
开发者ID:halaei,项目名称:jalali,代码行数:26,代码来源:JalaliServiceProviderTest.php

示例2: extendValidator

 /**
  * Extend the Validator.
  *
  * @param Factory $factory
  */
 protected function extendValidator(Factory $factory)
 {
     $factory->replacer('required_if_has', function ($message, $attribute, $rule, $parameters) {
         return $this->setFieldsAndValues($message, $attribute, $rule, $parameters);
     });
     $factory->replacer('required_if_not', function ($message, $attribute, $rule, $parameters) {
         return $this->setFieldsAndValues($message, $attribute, $rule, $parameters);
     });
     /////////////////////
     // Required if NOT //
     /////////////////////
     $factory->extendImplicit('required_if_not', function ($attribute, $value, $parameters = []) {
         $input = $this->input();
         $field = $parameters[0];
         $fieldValue = $parameters[1];
         // If the field is not set, default to true
         if (!array_key_exists($field, $input)) {
             return true;
         }
         return $input[$field] !== $fieldValue ? array_key_exists($attribute, $input) : true;
     }, "La question ':attribute' est requise lorsque la question ':field' n'est pas ':value' !");
     //////////////////////////////////
     // If checkbox contains a value //
     //////////////////////////////////
     $factory->extendImplicit('required_if_has', function ($attribute, $value, $parameters = []) {
         $input = $this->input();
         $field = $parameters[0];
         $fieldValue = $parameters[1];
         // If the field is not set, default to true
         if (!array_key_exists($field, $input)) {
             return true;
         }
         return array_key_exists($fieldValue, $input[$field]) ? array_key_exists($attribute, $input) : true;
     }, "La question ':attribute' est requise lorsque la question ':field' contient ':value' !");
 }
开发者ID:rleger,项目名称:TheseEcho,代码行数:40,代码来源:ValidatorExtentionsTrait.php

示例3: extendValidator

 /**
  * Extend validator.
  *
  * @param  string         $name
  * @param  string         $class
  * @param  \Closure|null  $replacer
  */
 private function extendValidator($name, $class, Closure $replacer = null)
 {
     $this->validator->extend($name, $class . '@validate' . studly_case($name));
     if (!is_null($replacer)) {
         $this->validator->replacer($name, $replacer);
     }
 }
开发者ID:arcanesoft,项目名称:auth,代码行数:14,代码来源:ValidatorServiceProvider.php

示例4: registerJDateTimeRules

 /**
  * @param JalaliValidator $validator
  */
 private function registerJDateTimeRules(JalaliValidator $validator)
 {
     $this->factory->extend('jdatetime', function ($attribute, $value, $parameter) use($validator) {
         return $validator->validateJDateTime($attribute, $value, $parameter);
     });
     $this->factory->extend('jdatetime_after', function ($attribute, $value, $parameter) use($validator) {
         return $validator->validateJDateTimeAfter($attribute, $value, $parameter);
     });
     $this->factory->extend('jdatetime_before', function ($attribute, $value, $parameter) use($validator) {
         return $validator->validateJDateTimeBefore($attribute, $value, $parameter);
     });
     $this->factory->replacer('jdatetime', function ($message, $attribute, $rule, $parameter) use($validator) {
         return $validator->replaceJalali($message, $attribute, $rule, $parameter);
     });
     $this->factory->replacer('jdatetime_after', function ($message, $attribute, $rule, $parameter) use($validator) {
         return $validator->replaceAfterOrBefore($message, $attribute, $rule, $parameter);
     });
     $this->factory->replacer('jdatetime_before', function ($message, $attribute, $rule, $parameter) use($validator) {
         return $validator->replaceAfterOrBefore($message, $attribute, $rule, $parameter);
     });
 }
开发者ID:opilo,项目名称:farsi,代码行数:24,代码来源:FarsiServiceProviderTest.php

示例5: register

 /**
  * Register the service provider.
  *
  * @return void
  */
 public function register()
 {
     $this->registerPresenceVerifier();
     $this->app->singleton('validator', function ($app) {
         $validator = new Factory($app['translator'], $app);
         // The validation presence verifier is responsible for determining the existence
         // of values in a given data collection, typically a relational database or
         // other persistent data stores. And it is used to check for uniqueness.
         if (isset($app['validation.presence'])) {
             $validator->setPresenceVerifier($app['validation.presence']);
         }
         // Add validation extensions
         $extensions = config('esensi/core::validation.extensions', []);
         foreach ($extensions as $extension => $class) {
             $validator->extend($extension, $class . '@validate' . ucfirst(studly_case($extension)));
             $validator->replacer($extension, $class . '@replace' . ucfirst(studly_case($extension)));
         }
         return $validator;
     });
 }
开发者ID:esensi,项目名称:core,代码行数:25,代码来源:ValidationServiceProvider.php

示例6: replacer

 /**
  * Register a custom implicit validator message replacer.
  *
  * @param string $rule
  * @param \Closure|string $replacer
  * @return void 
  * @static 
  */
 public static function replacer($rule, $replacer)
 {
     \Illuminate\Validation\Factory::replacer($rule, $replacer);
 }
开发者ID:satriashp,项目名称:tour,代码行数:12,代码来源:_ide_helper.php

示例7: replacer

 /**
  * Register a custom implicit validator message replacer.
  *
  * @param  string $rule
  * @param  \Closure|string $replacer
  * @return void
  */
 public function replacer($rule, $replacer)
 {
     $this->factory->replacer($rule, $replacer);
 }
开发者ID:Kremon,项目名称:laravel-jsvalidation,代码行数:11,代码来源:Factory.php


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