Updates to service updating - broadband

This commit is contained in:
Deon George
2022-08-01 20:34:10 +10:00
parent de3f1a534b
commit 7feec266b8
11 changed files with 234 additions and 73 deletions

43
app/Rules/IPv6_CIDR.php Normal file
View File

@@ -0,0 +1,43 @@
<?php
namespace App\Rules;
use Illuminate\Contracts\Validation\Rule;
class IPv6_CIDR implements Rule
{
private const MAX=128;
/**
* Determine if the validation rule passes.
*
* @param string $attribute
* @param mixed $value
* @return bool
*/
public function passes($attribute, $value)
{
if (str_contains($value,':') && str_contains($value,'/')) {
list($value,$mask) = explode('/',$value);
$m = filter_var($mask,\FILTER_VALIDATE_INT,[
'options' => [
'min_range' => 0,
"max_range" => self::MAX,
]
]);
return $m && filter_var($value,\FILTER_VALIDATE_IP,\FILTER_FLAG_IPV6);
}
}
/**
* Get the validation error message.
*
* @return string
*/
public function message()
{
return 'The :attribute must be a valid IPv6 CIDR range.';
}
}