for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace SimpleCMS\Region\Validation\Rule;
use SimpleCMS\Region\Validation\RegionZip;
use Illuminate\Contracts\Validation\ValidationRule;
/**
* 邮政编码
*
* @author Dennis Lui <[email protected]>
*/
class RegionZipRule implements ValidationRule
{
* Run the validation rule.
* @param string $attribute
* @param mixed $value
* @param \Closure(string): \Illuminate\Translation\PotentiallyTranslatedString $fail
* @return void
public function validate(string $attribute, mixed $value, \Closure $fail): void
if (!$this->passes($attribute, $value)) {
$fail($this->message());
}
* Determine if the validation rule passes.
* @return bool
public function passes($attribute, $value)
$attribute
If this is a false-positive, you can also ignore this issue in your code via the ignore-unused annotation
ignore-unused
public function passes(/** @scrutinizer ignore-unused */ $attribute, $value)
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.
return (new RegionZip($value))->isValid();
* Get the validation error message.
* @return string|array
public function message()
return 'The :attribute is incorrect.';
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.