PHP Class Propaganistas\LaravelPhone\PhoneValidator

Afficher le fichier Open project: propaganistas/laravel-phone

Protected Properties

Свойство Type Description
$autodetect boolean Whether the country should be auto-detected.
$countries array Countries to validate against.
$countryField string | null The field to use for country if not passed as a parameter.
$data array Dotted validator data.
$lenient boolean Whether to allow lenient checking of numbers (i.e. landline without area codes).
$lib libphonenumber\PhoneNumberUtil
$types array Transformed phone number types to validate against.

Méthodes publiques

Méthode Description
__construct ( PhoneNumberUtil $lib ) PhoneValidator constructor.
isInputField ( string $field ) : boolean Checks if the given field is an actual input field.
isPhoneCountry ( string $country ) : boolean Checks if the supplied string is a valid country code.
isPhoneType ( string $type ) : boolean Checks if the supplied string is a valid phone number type.
validatePhone ( string $attribute, mixed $value, array $parameters, object $validator ) : boolean Validates a phone number.

Méthodes protégées

Méthode Description
assignParameters ( array $parameters ) Parses the supplied validator parameters.
checkCountries ( string $attribute ) Checks the detected countries. Overrides countries if a country field is present.
isValidNumber ( mixed $number, null $country = null ) : boolean Performs the actual validation of the phone number.
parseTypes ( array $types ) : array Parses the supplied phone number types.

Method Details

__construct() public méthode

PhoneValidator constructor.
public __construct ( PhoneNumberUtil $lib )
$lib libphonenumber\PhoneNumberUtil

assignParameters() protected méthode

Parses the supplied validator parameters.
protected assignParameters ( array $parameters )
$parameters array

checkCountries() protected méthode

When using a country field, we should validate to false if country is empty so no exception will be thrown.
protected checkCountries ( string $attribute )
$attribute string

isInputField() public méthode

Checks if the given field is an actual input field.
public isInputField ( string $field ) : boolean
$field string
Résultat boolean

isPhoneCountry() public méthode

Checks if the supplied string is a valid country code.
public isPhoneCountry ( string $country ) : boolean
$country string
Résultat boolean

isPhoneType() public méthode

Checks if the supplied string is a valid phone number type.
public isPhoneType ( string $type ) : boolean
$type string
Résultat boolean

isValidNumber() protected méthode

Performs the actual validation of the phone number.
protected isValidNumber ( mixed $number, null $country = null ) : boolean
$number mixed
$country null
Résultat boolean

parseTypes() protected méthode

Parses the supplied phone number types.
protected parseTypes ( array $types ) : array
$types array
Résultat array

validatePhone() public méthode

Validates a phone number.
public validatePhone ( string $attribute, mixed $value, array $parameters, object $validator ) : boolean
$attribute string
$value mixed
$parameters array
$validator object
Résultat boolean

Property Details

$autodetect protected_oe property

Whether the country should be auto-detected.
protected bool $autodetect
Résultat boolean

$countries protected_oe property

Countries to validate against.
protected array $countries
Résultat array

$countryField protected_oe property

The field to use for country if not passed as a parameter.
protected string|null $countryField
Résultat string | null

$data protected_oe property

Dotted validator data.
protected array $data
Résultat array

$lenient protected_oe property

Whether to allow lenient checking of numbers (i.e. landline without area codes).
protected bool $lenient
Résultat boolean

$lib protected_oe property

protected PhoneNumberUtil,libphonenumber $lib
Résultat libphonenumber\PhoneNumberUtil

$types protected_oe property

Transformed phone number types to validate against.
protected array $types
Résultat array