function __construct() { Parent::__construct(); Validator::extend('total', function ($attribute, $value, $parameters, $validator) { $value != 100 ? $check = false : ($check = true); return $check; }); }
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); }); }
/** * 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"); }); }
/** * 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); }); }
/** * 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]; }); }
/** * 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; }); }
/** * 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); } }
/** * 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); }); }
/** * 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(); }); }
/** * Bootstrap any application services. * * @return void */ public function boot() { // validador solo para cadenas con espacios Validator::extend('alpha_spaces', function ($attribute, $value) { return preg_match('/^[\\pL\\s]+$/u', $value); }); }
/** * 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); }); }
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'); }
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); }); }
/** * 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); }); }
/** * 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'); }
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'); }
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'); }
/** * Bootstrap any application services. * * @return void */ public function boot() { Validator::extend('user', function ($attribute, $value, $parameters) { if (VerifiedEmail::where('email', $value)->count() > 0 || User::where('username', $value)->count() > 0) { return true; } return false; }); }
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); }); }
/** * 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.'); }); }
/** * Register the service provider. * * @return void */ public function register() { Validator::extend('mobile', function ($attribute, $value, $parameters) { return preg_match("/^1[0-9]{2}[0-9]{8}\$|15[0189]{1}[0-9]{8}\$|189[0-9]{8}\$/", $value); }); Validator::extend('code', function ($attribute, $value, $parameters) { return strlen($value) != 6 || !preg_match("/[0-9]{6}/", $value); }); }
/** * Bootstrap the application services. * * @return void */ public function boot() { Validator::extend('current_pass', function ($attribute, $value, $parameters, $validator) { $user = Auth::user(); if (Hash::make($value) !== $user->password) { return FALSE; } return TRUE; }); }
/** * 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; }); }
/** * Bootstrap any application services. * * @return void */ public function boot() { // Validator::extend('full_name', function ($attribute, $value, $parameters) { return preg_match('/\\w+ \\w+ \\w+/', $value) === 1; }); Validator::extend('selected', function ($attribute, $value, $parameters) { return $value != 'unselected'; }); }
/** * Bootstrap any application services. * * @return void */ public function boot() { Auth::provider('neo4j', function () { // Return an instance of Illuminate\Contracts\Auth\UserProvider... return new Neo4jUserProvider(); }); Validator::extend('jsonMax', function ($attribute, $value, $parameters, $validator) { return count(json_decode($value)) <= array_shift($parameters); }); }
/** * We need a custom validator, so domain rules must be specified * as part of the getRules method. * * @return array */ public function getRules() { Validator::extend('domainFormat', function ($field, $value) { $domainValidation = '([a-z0-9]+\\.)?([a-z0-9\\-]+)\\.([a-z]{2,3})'; $ipPortValidation = '([0-9]{1,3})\\.([0-9]{1,3})\\.([0-9]{1,3})\\.([0-9]{1,3})(:[0-9]{2,5})?'; return preg_match("/^(({$domainValidation})|({$ipPortValidation}))\$/i", $value); }); $rules = ['domain' => ['required', 'domainFormat', 'unique:domains,domain,' . $this->getValue('id')]]; return $rules; }
/** * Bootstrap any application services. * * @return void */ public function boot() { Validator::extend('torrentFile', function ($attribute, $value, $parameters, $validator) { $dictionary = BencodeHelper::decodeFile($value); list($announce, $info) = BencodeHelper::checkDictionary($dictionary, "announce(string):info", "global dictionary"); list($dname, $plen, $pieces) = BencodeHelper::checkDictionary($info, "name(string):piece length(integer):pieces(string)", "Info dictionary"); $total_length = BencodeHelper::getDictionaryValue($info, "length", "integer"); $dicttionary_is_valid = BencodeHelper::checkDictionary($dictionary, "announce(string):info", "global dictionary") == BencodeHelper::_OK; return $dicttionary_is_valid && (int) $total_length > 0 && (int) $plen > 0 && $pieces !== "" && $announce !== ""; }); }
/** * Boot the service provider. * * @return void */ public function boot() { $this->defineRoutes(); $this->defineResources(); Validator::extend('state', StateValidator::class . '@validate'); Validator::extend('country', CountryValidator::class . '@validate'); Validator::extend('vat_id', VatIdValidator::class . '@validate'); Auth::viaRequest('spark', function ($request) { return app(TokenGuard::class)->user($request); }); }
/** * loadCustomValidation * * @author Vincent Sposato <*****@*****.**> * @version v1.0 * @return boolean */ private function loadCustomValidation() { $customValidations = Config::get('validation_service'); if (sizeof($customValidations) === 0 || !is_array($customValidations)) { return true; } // Loop through our custom validations, and add them to the extender foreach ($customValidations as $validationName => $validationClassMethod) { Validator::extend($validationName, $validationClassMethod); } return true; }
/** * Bootstrap the application services. * * @return void */ public function boot() { Validator::extend('serverdomain', function ($attribute, $value, $parameters) { if (strpos($value, "uva.nl") !== false) { return false; } if (!checkdnsrr($value, "A")) { return false; } return true; }); }