當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。