mirror of https://github.com/YGGverse/net-php.git
yggverse
9 months ago
1 changed files with 40 additions and 0 deletions
@ -0,0 +1,40 @@
@@ -0,0 +1,40 @@
|
||||
<?php |
||||
|
||||
declare(strict_types=1); |
||||
|
||||
namespace Yggverse\Net; |
||||
|
||||
class Valid |
||||
{ |
||||
public static function ip(mixed $value): bool |
||||
{ |
||||
return self::ip4($value) || self::ip6($value); |
||||
} |
||||
|
||||
public static function ip4(mixed $value): bool |
||||
{ |
||||
return false !== filter_var( |
||||
$value, |
||||
FILTER_VALIDATE_IP, |
||||
FILTER_FLAG_IPV4 |
||||
); |
||||
} |
||||
|
||||
public static function ip6(mixed $value): bool |
||||
{ |
||||
return false !== filter_var( |
||||
$value, |
||||
FILTER_VALIDATE_IP, |
||||
FILTER_FLAG_IPV6 |
||||
); |
||||
} |
||||
|
||||
public static function domainHostName(mixed $value): bool |
||||
{ |
||||
return false !== filter_var( |
||||
$value, |
||||
FILTER_VALIDATE_DOMAIN, |
||||
FILTER_FLAG_HOSTNAME |
||||
); |
||||
} |
||||
} |
Loading…
Reference in new issue