-
Notifications
You must be signed in to change notification settings - Fork 2
Network
- Dns
- Domain
- IpAddress
- Url
Validates the input (string address) to have a MX DNS record.
Available since: 1.0.0
<?php declare(strict_types);
use HarmonyIO\Validation\Rule\Network\Dns\MxRecord;
(new MxRecord())->validate('example.com');-
Type.Stringwhen the validated value is not a string -
Network.Dns.MxRecordwhen the validated value does not contain an MX record
Validates the input (string address) to have a DNS record of type \HarmonyIO\Validation\Enum\Network\Dns\RecordType.
Available since: 1.0.0
<?php declare(strict_types);
use HarmonyIO\Validation\Enum\Network\Dns\RecordType;
use HarmonyIO\Validation\Rule\Network\Dns\RecordExists;
(new RecordExists(RecordType::A()))->validate('example.com');-
Type.Stringwhen the validated value is not a string -
Network.Dns.RecordExistswhen the validated value does not contain the defined record type
Validates the input (string TLD) to ba a valid and registered Tld.
Available since: 1.0.0
<?php declare(strict_types);
use Amp\Artax\DefaultClient;
use Amp\Redis\Client;
use HarmonyIO\Cache\Provider\Redis;
use HarmonyIO\HttpClient\Client\ArtaxClient;
use HarmonyIO\Validation\Rule\Network\Domain\Tld;
$httpClient = new ArtaxClient(new DefaultClient(), new Redis(new Client('tcp://127.0.0.1:6379')));
(new Tld($httpClient))->validate('com');Note: the source of valid TLDs is retrieved from IANA (https://data.iana.org/TLD/tlds-alpha-by-domain.txt)and is cached for 7 days.
-
Type.Stringwhen the validated value is not a string -
Network.Domain.Tldwhen the validated value is not a valid TLD
Validates the input (string ip address) to be in the defined range (string ...$cidrRange).
Available since: 1.0.0
<?php declare(strict_types);
use HarmonyIO\Validation\Rule\Network\IpAddress\InCidrRange;
(new InCidrRange('192.168.100.0/24'))->validate('192.168.210.10');-
Type.Stringwhen the validated value is not a string -
Network.IpAddress.InCidrRangewhen the validated value is not within the specified range
Validates the input (string ip address) to be a valid IPv4 address.
Available since: 1.0.0
<?php declare(strict_types);
use HarmonyIO\Validation\Rule\Network\IpAddress\IPv4;
(new Ipv4())->validate('192.168.210.10');-
Type.Stringwhen the validated value is not a string -
Network.IpAddress.Ipv4when the validated value is not a valid IPv4 address
Validates the input (string ip address) to be a valid IPv6 address.
Available since: 1.0.0
<?php declare(strict_types);
use HarmonyIO\Validation\Rule\Network\IpAddress\IPv6;
(new Ipv6())->validate('2001:0db8:85a3:0000:0000:8a2e:0370:7334');-
Type.Stringwhen the validated value is not a string -
Network.IpAddress.Ipv6when the validated value is not a valid IPv6 address
Validates the input (string ip address) to not be a private IP address.
Available since: 1.0.0
<?php declare(strict_types);
use HarmonyIO\Validation\Rule\Network\IpAddress\NotInPrivateRange;
(new NotInPrivateRange())->validate('80.24.72.48');-
Type.Stringwhen the validated value is not a string -
Network.IpAddress.NotInPrivateRangewhen the validated value is in one of the private ranges of IP addresses
Validates the input (string ip address) to not be a reserved IP address.
Available since: 1.0.0
<?php declare(strict_types);
use HarmonyIO\Validation\Rule\Network\IpAddress\NotInReservedRange;
(new NotInReservedRange())->validate('80.24.72.48');-
Type.Stringwhen the validated value is not a string -
Network.IpAddress.NotInReservedRangewhen the validated value is a reserved IP addresses
Validates the input (string) URL to return a HTTP status 200.
Available since: 1.0.0
<?php declare(strict_types);
use Amp\Artax\DefaultClient;
use Amp\Redis\Client;
use HarmonyIO\Cache\Provider\Redis;
use HarmonyIO\HttpClient\Client\ArtaxClient;
use HarmonyIO\Validation\Rule\Network\Url\OkResponse;
$httpClient = new ArtaxClient(new DefaultClient(), new Redis(new Client('tcp://127.0.0.1:6379')));
(new OkResponse($httpClient))->validate('https://example.com');-
Type.Stringwhen the validated value is not a string -
Network.Url.OkResponsewhen the URL does not result in a 200 HTTP response
Validates the input (string) URL to be syntactically valid.
Available since: 1.0.0
<?php declare(strict_types);
use HarmonyIO\Validation\Rule\Network\Url\Url;
(new Url())->validate('https://example.com');-
Type.Stringwhen the validated value is not a string -
Network.Url.Urlwhen the URL is not valid