Browse Source

implement validation class

main 1.7.0
yggverse 9 months ago
parent
commit
b37f28ce4f
  1. 40
      src/Valid.php

40
src/Valid.php

@ -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…
Cancel
Save