Luminova Framework

PHP Luminova: Validating Common Value Formats

Last updated: 2026-11-28 20:57:12

Check deterministic identifiers, email addresses, URLs, phone values, binary data, check digits, integers, and geographic coordinates.

Use these static checks when working with an individual value. For complete request validation and field errors, see Input Validation. A format check cannot establish that an email address, phone number, or URL is reachable.


Usage

use Luminova\Utility\Validator;

$email = '[email protected]';
var_dump(Validator::isEmail($email)); // bool(true)

$valid = Validator::isLatLng('3.1390', '101.6869', strict: true, precision: 4);
var_dump($valid); // bool(true)

Class Definition

  • Full namespace: Luminova\Utility\Validator
  • This class is final.

Methods

isIdentifier

Check the identifier format, regenerate it, and compare with hash_equals(). Pass the same algorithm, length, and grouping options used to generate the identifier. This method defaults to xxh128, while Random::identifier() defaults to sha256.

public static function isIdentifier(
    string $from,
    string $identifier,
    int $length = 23,
    int $group = 5,
    string $algo = 'xxh128'
): bool

Parameters:

ParameterTypeDescription
$fromstringOriginal source value.
$identifierstringIdentifier to verify.
$lengthintRequested identifier length (default: 23).
$groupintGroup size (default: 5).
$algostringHash algorithm (default: 'xxh128').

Return:

bool - Whether the identifier matches.

Throws:

Examples:

use Luminova\Utility\Random;
use Luminova\Utility\Validator;

$id = Random::identifier('order-1001', algo: 'sha256');
var_dump(Validator::isIdentifier('order-1001', $id, algo: 'sha256')); // bool(true)

isEmail

Checks if string is a valid email address, with optional support for internationalized domains.

public static function isEmail(
    mixed $email,
    array $rejectDomains = [],
    bool $allowIdn = false
): bool

Parameters:

ParameterTypeDescription
$emailmixedEmail address to validate.
$rejectDomainsarray<int\|string,mixed>List of domains to reject (e.g. ['example.com']) (default: []).
$allowIdnboolAllow internationalized domains (default: false).

Return:

bool - Returns true if valid email address, false otherwise.


isUrl

Checks if the string is a valid URL, with optional support for internationalized domains.

public static function isUrl(mixed $url, bool $allowIdn = false, bool $httpOnly = false): bool

Parameters:

ParameterTypeDescription
$urlmixedThe URL to validate.
$allowIdnboolWhether to allow internationalized domain names (default: false).
$httpOnlyboolRestrict to http/https schemes only (default: false).

Return:

bool - True if valid URL, otherwise false.


isPhone

Validates if the input is a valid phone number.

public static function isPhone(mixed $phone, int $min = 10, int $max = 15): bool

Parameters:

ParameterTypeDescription
$phonemixedThe phone number to validate.
$minintThe minimum allowed length (default: 10).
$maxintThe maximum allowed length (default: 15).

Return:

bool - Returns true if valid phone number, false otherwise.


isBinary

Determines if the content string is likely a binary based on the presence of non-printable characters.

public static function isBinary(mixed $data): bool

Parameters:

ParameterTypeDescription
$datamixedThe string or resource to check for binary.

Return:

bool - Return true if it's a binary, false otherwise.


isValidCheckDigit

Check the final digit of a barcode or the trailing two characters of a GMN. The barcode check uses the same weighting as Random, so it can differ from standard EAN-13 or UPC-A validation.

public static function isValidCheckDigit(string $code, ?string $type = null): bool

Parameters:

ParameterTypeDescription
$codestringCode including its check digit or characters.
$typestring\|nullType such as ean, ean-13, upc, upc-a, barcode, or gmn. Pass null for a generic barcode (default: null).

Return:

bool - Whether the format and computed check value match.


isBigInteger

Check a decimal integer against inclusive string bounds. With no bounds, the comparison uses the unsigned 64-bit range. Pass a string for values larger than PHP’s integer range.

public static function isBigInteger(
    mixed $input,
    ?string $min = null,
    ?string $max = null
): bool

Parameters:

ParameterTypeDescription
$inputmixedCandidate integer value.
$minstring\|nullLower bound. Uses zero when omitted (default: null).
$maxstring\|nullUpper bound. Uses the unsigned 64-bit maximum when omitted (default: null).

Return:

bool - Whether the value passes format and range checks.


isLat

Check a latitude from −90 to 90 degrees.

public static function isLat(mixed $lat, bool $strict = false, ?int $precision = null): bool

Parameters:

ParameterTypeDescription
$latmixedLatitude value.
$strictboolWhether to enforce decimal notation and precision (default: false).
$precisionint\|nullMaximum decimal places when strict mode is enabled (default: null).

Return:

bool - Whether the latitude passes the selected checks.


isLng

Check a longitude from −180 to 180 degrees.

public static function isLng(mixed $lng, bool $strict = false, ?int $precision = null): bool

Parameters:

ParameterTypeDescription
$lngmixedLongitude value.
$strictboolWhether to enforce decimal notation and precision (default: false).
$precisionint\|nullMaximum decimal places when strict mode is enabled (default: null).

Return:

bool - Whether the longitude passes the selected checks.


isLatLng

Run both coordinate checks with the same strictness and precision.

public static function isLatLng(
    mixed $lat,
    mixed $lng,
    bool $strict = false,
    ?int $precision = null
): bool

Parameters:

ParameterTypeDescription
$latmixedLatitude value.
$lngmixedLongitude value.
$strictboolWhether to enforce decimal notation and precision (default: false).
$precisionint\|nullMaximum decimal places when strict mode is enabled (default: null).

Return:

bool - Whether both coordinates pass.