clrghouz/app/Rules/FidoInteger.php
Deon George 7ef9f2dbd0
All checks were successful
Create Docker Image / Build Docker Image (x86_64) (push) Successful in 40s
Create Docker Image / Build Docker Image (arm64) (push) Successful in 1m46s
Create Docker Image / Final Docker Image Manifest (push) Successful in 11s
Fix/optimise address creation/editing via System AKAs
2024-05-27 21:42:03 +10:00

33 lines
695 B
PHP

<?php
namespace App\Rules;
use Illuminate\Contracts\Validation\Rule;
use App\Models\Address;
class FidoInteger implements Rule
{
/**
* Determine if the validation rule passes.
* This will check that a number used for zone, net, host is between 0 and Address::ADDRESS_FIELD_MAX.
*
* @param string $attribute
* @param mixed $value
* @return bool
*/
public function passes($attribute,$value)
{
return (is_numeric($value) && ($value >= 0) && ($value < Address::ADDRESS_FIELD_MAX));
}
/**
* Get the validation error message.
*
* @return string
*/
public function message()
{
return sprintf('The number must be between 0 and %d.',Address::ADDRESS_FIELD_MAX);
}
}