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


PHP Validator::extend方法代码示例

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


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

示例1: function

 function __construct()
 {
     Parent::__construct();
     Validator::extend('total', function ($attribute, $value, $parameters, $validator) {
         $value != 100 ? $check = false : ($check = true);
         return $check;
     });
 }
开发者ID:younginnovations,项目名称:aidstream,代码行数:8,代码来源:CountryBudgetItem.php

示例2: 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

示例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], "Max cannot be less than min");
     });
 }
开发者ID:apatel23,项目名称:CSCI445_final_project_12_6,代码行数:17,代码来源:AppServiceProvider.php

示例4: boot

 /**
  * Bootstrap any application services.
  *
  * @return void
  */
 public function boot()
 {
     Validator::extend('text', function ($attribute, $value) {
         //Alpha dash with space,dot and newline
         return preg_match('/^[\\n\\. \\pL\\pM\\pN_-]+$/u', $value);
     });
 }
开发者ID:pshanoop,项目名称:laravel-blog,代码行数:12,代码来源:AppServiceProvider.php

示例5: boot

 /**
  * Bootstrap the application services.
  *
  * @return void
  */
 public function boot()
 {
     //Used to check if surf start is before end. Can't surf time travel :)
     Validator::extend('surftime', function ($attribute, $value, $parameters, $validator) {
         return $value >= $parameters[0];
     });
 }
开发者ID:shauno,项目名称:sesh.co.za,代码行数:12,代码来源:SeshApiProvider.php

示例6: boot

 /**
  * Bootstrap any application services.
  *
  * @return void
  */
 public function boot()
 {
     Validator::extend('hashed', function ($attribute, $value, $parameters) {
         // If we're already logged in
         if (Auth::check()) {
             $user = Auth::user();
         } else {
             // Otherwise, try to get the username from form input
             $user = User::where('name', Input::get('name'))->get();
             if (!$user->count()) {
                 return false;
             }
             $user = $user[0];
         }
         if (Hash::check($value, $user->password)) {
             return true;
         }
         return false;
     });
     Validator::extend('time', function ($attribute, $value, $parameters) {
         $value = trim($value);
         // Check against 12 hour time (with AM/PM) or 24 hour time
         $twelve = date_parse_from_format('h:i a', $value);
         $twentyfour = date_parse_from_format('H:i', $value);
         if ($twelve['error_count'] === 0 || $twentyfour['error_count'] === 0) {
             return true;
         }
         return false;
     });
 }
开发者ID:playatech,项目名称:laravel-voldb,代码行数:35,代码来源:AppServiceProvider.php

示例7: registerValidationRules

 /**
  * Registers validation rules
  */
 protected function registerValidationRules()
 {
     $rules = ['not_reserved_name' => 'NotReservedName', 'date_mysql' => 'DateMysql'];
     foreach ($rules as $name => $rule) {
         Validator::extend($name, 'Reactor\\Support\\Validation\\FormValidator@validate' . $rule);
     }
 }
开发者ID:NuclearCMS,项目名称:Nuclear,代码行数:10,代码来源:ReactorServiceProvider.php

示例8: boot

 /**
  * Bootstrap any application services.
  *
  * @return void
  */
 public function boot()
 {
     Validator::extend('strp', function ($attribute, $value, $parameters) {
         // compare the entered password with what the database has, e.g. validates the current password
         return strip_tags($value);
     });
 }
开发者ID:myleshyson,项目名称:ivgainesville,代码行数:12,代码来源:AppServiceProvider.php

示例9: boot

 /**
  * Bootstrap any application services.
  *
  * @return void
  */
 public function boot()
 {
     Validator::extend('check_auth_user_password', function ($attribute, $value, $parameters, $validator) {
         return Hash::check($value, Auth::user()->password);
     });
     // Make sure client email is not used by another client of current user
     Validator::extend('email_not_used_by_another_user_client', function ($attribute, $value, $parameters, $validator) {
         if (Client::where('user_id', Auth::user()->id)->where('email', $value)->count()) {
             return false;
         }
         return true;
     });
     // Make sure client phone number is not user by another client of current user
     Validator::extend('phone_number_not_used_by_another_user_client', function ($attribute, $value, $parameters, $validator) {
         if (Client::where('user_id', Auth::user()->id)->where('phone_number', $value)->count()) {
             return false;
         }
         return true;
     });
     Validator::extend('not_exists', function ($attribute, $value, $parameters, $validator) {
         return !DB::table($parameters[0])->where($parameters[1], $value)->count();
     });
     Validator::extend('is_not_in_auth_user_products', function ($attribute, $value, $parameters, $validator) {
         return !DB::table('products')->where('user_id', \Auth::user()->id)->where('code', $value)->count();
     });
 }
开发者ID:bitller,项目名称:nova,代码行数:31,代码来源:AppServiceProvider.php

示例10: boot

 /**
  * Bootstrap any application services.
  *
  * @return void
  */
 public function boot()
 {
     // Add some custom validation rules
     Validator::extend('valid_path', function ($attribute, $value, $parameters, $validator) {
         return is_dir($value) && is_readable($value);
     });
 }
开发者ID:Holdlen2DH,项目名称:koel,代码行数:12,代码来源:AppServiceProvider.php

示例11: extendValidators

 public function extendValidators()
 {
     // Function to call the Uuid validator
     Validator::extend('currency_code', function ($attribute, $value) {
         $currency = new CurrencyService();
         return $currency->checkCurrency($value);
     }, 'Currency code is incorrect');
 }
开发者ID:leloulight,项目名称:api,代码行数:8,代码来源:CustomValidator.php

示例12: function

 function __construct()
 {
     Validator::extend('activity_file', function ($attribute, $value, $parameters, $validator) {
         $mimes = ['application/excel', 'application/vnd.ms-excel', 'application/msexcel', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'text/csv'];
         $fileMime = $value->getClientMimeType();
         return in_array($fileMime, $mimes);
     });
 }
开发者ID:younginnovations,项目名称:aidstream,代码行数:8,代码来源:UploadActivity.php

示例13: boot

 /**
  * Bootstrap the application services.
  *
  * @return void
  */
 public function boot()
 {
     Validator::extend('at_least_one_admin', 'App\\Validators\\RoleValidators@atLeastOneAdmin');
     Validator::extend('own_admin_role', 'App\\Validators\\RoleValidators@ownAdminRole');
     Validator::resolver(function ($translator, $data, $rules, $messages) {
         return new Validation($translator, $data, $rules, $messages);
     });
 }
开发者ID:guenthertheilen,项目名称:laravel-boilerplate,代码行数:13,代码来源:ValidationServiceProvider.php

示例14: boot

 /**
  * Bootstrap the application services.
  *
  * @return void
  */
 public function boot()
 {
     $this->loadTranslationsFrom(__DIR__ . '/../resources/lang/', 'calendar-events');
     $this->loadViewsFrom(__DIR__ . '/../resources/views/', 'calendar-events');
     $this->publishes([__DIR__ . '/../database/migrations/' => database_path('migrations/'), __DIR__ . '/../config/' => config_path('calendar-events/'), __DIR__ . '/../resources/lang/' => base_path('resources/lang/'), __DIR__ . '/../resources/views/' => base_path('resources/vendor/calendar-events/'), __DIR__ . '/../public/js/' => public_path('/js/')]);
     Validator::extend('time', '\\Todstoychev\\CalendarEvents\\Validator\\CalendarEventsValidator@validateTime');
     Validator::extend('dates_array', '\\Todstoychev\\CalendarEvents\\Validator\\CalendarEventsValidator@validateDatesArray');
 }
开发者ID:todstoychev,项目名称:calendar-events,代码行数:13,代码来源:CalendarEventsServiceProvider.php

示例15: 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


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