芝麻web文件管理V1.00
编辑当前文件:/home/qrafawbu/tblonline.org/vendor/laravel/framework/src/Illuminate/Validation/Rules/Password.php
min = max((int) $min, 1); } /** * Set the default callback to be used for determining a password's default rules. * * If no arguments are passed, the default password rule configuration will be returned. * * @param static|callable|null $callback * @return static|null */ public static function defaults($callback = null) { if (is_null($callback)) { return static::default(); } if (! is_callable($callback) && ! $callback instanceof static) { throw new InvalidArgumentException('The given callback should be callable or an instance of '.static::class); } static::$defaultCallback = $callback; } /** * Get the default configuration of the password rule. * * @return static */ public static function default() { $password = is_callable(static::$defaultCallback) ? call_user_func(static::$defaultCallback) : static::$defaultCallback; return $password instanceof Rule ? $password : static::min(8); } /** * Get the default configuration of the password rule and mark the field as required. * * @return array */ public static function required() { return ['required', static::default()]; } /** * Get the default configuration of the password rule and mark the field as sometimes being required. * * @return array */ public static function sometimes() { return ['sometimes', static::default()]; } /** * Set the performing validator. * * @param \Illuminate\Contracts\Validation\Validator $validator * @return $this */ public function setValidator($validator) { $this->validator = $validator; return $this; } /** * Set the data under validation. * * @param array $data * @return $this */ public function setData($data) { $this->data = $data; return $this; } /** * Sets the minimum size of the password. * * @param int $size * @return $this */ public static function min($size) { return new static($size); } /** * Ensures the password has not been compromised in data leaks. * * @param int $threshold * @return $this */ public function uncompromised($threshold = 0) { $this->uncompromised = true; $this->compromisedThreshold = $threshold; return $this; } /** * Makes the password require at least one uppercase and one lowercase letter. * * @return $this */ public function mixedCase() { $this->mixedCase = true; return $this; } /** * Makes the password require at least one letter. * * @return $this */ public function letters() { $this->letters = true; return $this; } /** * Makes the password require at least one number. * * @return $this */ public function numbers() { $this->numbers = true; return $this; } /** * Makes the password require at least one symbol. * * @return $this */ public function symbols() { $this->symbols = true; return $this; } /** * Determine if the validation rule passes. * * @param string $attribute * @param mixed $value * @return bool */ public function passes($attribute, $value) { $validator = Validator::make($this->data, [ $attribute => 'string|min:'.$this->min, ], $this->validator->customMessages, $this->validator->customAttributes); if ($validator->fails()) { return $this->fail($validator->messages()->all()); } $value = (string) $value; if ($this->mixedCase && ! preg_match('/(\p{Ll}+.*\p{Lu})|(\p{Lu}+.*\p{Ll})/u', $value)) { $this->fail('The :attribute must contain at least one uppercase and one lowercase letter.'); } if ($this->letters && ! preg_match('/\pL/u', $value)) { $this->fail('The :attribute must contain at least one letter.'); } if ($this->symbols && ! preg_match('/\p{Z}|\p{S}|\p{P}/u', $value)) { $this->fail('The :attribute must contain at least one symbol.'); } if ($this->numbers && ! preg_match('/\pN/u', $value)) { $this->fail('The :attribute must contain at least one number.'); } if (! empty($this->messages)) { return false; } if ($this->uncompromised && ! Container::getInstance()->make(UncompromisedVerifier::class)->verify([ 'value' => $value, 'threshold' => $this->compromisedThreshold, ])) { return $this->fail( 'The given :attribute has appeared in a data leak. Please choose a different :attribute.' ); } return true; } /** * Get the validation error message. * * @return array */ public function message() { return $this->messages; } /** * Adds the given failures, and return false. * * @param array|string $messages * @return bool */ protected function fail($messages) { $messages = collect(Arr::wrap($messages))->map(function ($message) { return $this->validator->getTranslator()->get($message); })->all(); $this->messages = array_merge($this->messages, $messages); return false; } }