2021-07-01 14:25:41 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Rules;
|
|
|
|
|
|
|
|
use Illuminate\Contracts\Validation\Rule;
|
|
|
|
|
|
|
|
use App\Http\Controllers\DomainController;
|
|
|
|
|
|
|
|
class FidoInteger implements Rule
|
|
|
|
{
|
2023-06-27 07:39:11 +00:00
|
|
|
/**
|
|
|
|
* Determine if the validation rule passes.
|
2021-07-01 14:25:41 +00:00
|
|
|
* This will check that a number used for zone, net, host is between 1 and DomainController::NUMBER_MAX.
|
2023-06-27 07:39:11 +00:00
|
|
|
*
|
|
|
|
* @param string $attribute
|
|
|
|
* @param mixed $value
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
public function passes($attribute,$value)
|
|
|
|
{
|
|
|
|
return (is_numeric($value) && ($value >= 0) && ($value < DomainController::NUMBER_MAX));
|
|
|
|
}
|
2021-07-01 14:25:41 +00:00
|
|
|
|
2023-06-27 07:39:11 +00:00
|
|
|
/**
|
|
|
|
* Get the validation error message.
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function message()
|
|
|
|
{
|
|
|
|
return sprintf('The number must be between 0 and %d.',DomainController::NUMBER_MAX);
|
|
|
|
}
|
|
|
|
}
|