Menu

## Validator
in package
Uses ValidationTrait

Validator.php : 7

### Table of Contents

#### Properties

$ip_pattern : string
$password_pattern : string
$phone_pattern : string
$slug_pattern : string
$hayStack : Arrayable|null
$hook : string
$throwsExceptions : bool

#### Methods

allShouldBe() : Validator
asDomain() : Validator
asEmail() : Validator
  Validates emails of all formats
asInternationalPhone() : bool|int
  Will only validate international numbers if the code is provided, otherwise, will validate local only
asIp() : Validator
asMac() : Validator
asNumber() : static
asNumeric() : static
asNumericInt() : static
asPassword() : static
  Validates the rules as follows - At least one integer - At least one lowercase alpha letter - At least one Uppercase alpha letter - At least one special character
asSlug() : Validator
asUrl() : Validator
validate() : static
_validate() : bool|int
  Use this to cover scenarios this contract does not cover
_validateFilter() : int|bool
  Internal validator based on PHP filter_var validations
getOrFail() : mixed
shouldBe() : Validator

### Properties

#### $ip_pattern

ValidationTrait.php : 13
`public string $ip_pattern = "/^(\\d{1,3}\\.){3}\\d{1,3}\$/"`

#### $password_pattern

ValidationTrait.php : 12
`public string $password_pattern = "/^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)(?=.*(_|[^\\w])).+\$/"`

#### $phone_pattern

ValidationTrait.php : 11
`public string $phone_pattern = "/^[+]{1}(?:[0-9\\-\\(\\)\\/.]\\s?){6,15}[0-9]{1}\$/"`

#### $slug_pattern

ValidationTrait.php : 14
`public string $slug_pattern = "/^[a-z0-9-]+\$/"`

#### $hayStack

Validator.php : 13
`protected Arrayable|null $hayStack`

#### $hook

Validator.php : 11
`protected string $hook`

#### $throwsExceptions

ValidationTrait.php : 15
`private bool $throwsExceptions = true`

### Methods

#### allShouldBe()

ValidationTrait.php : 249
`public allShouldBe(string $expected[, string|null $message = 'Invalid data' ]) : Validator`

##### Parameters

$expected : string
$message : string|null = 'Invalid data'

##### Tags

throws
  Exception

##### Return values

Validator

#### asDomain()

ValidationTrait.php : 189
`public asDomain([string|null $regex = null ]) : Validator`

##### Parameters

$regex : string|null = null

  Your custom regular expression we can depend on instead.

##### Tags

throws
  Exception

##### Return values

Validator

#### asEmail()

ValidationTrait.php : 49

Validates emails of all formats

`public asEmail([string|null $regex = null ][, string|null $message = 'Invalid email address' ]) : Validator`

##### Parameters

$regex : string|null = null
$message : string|null = 'Invalid email address'

##### Tags

throws
  Exception

##### Return values

Validator

#### asInternationalPhone()

ValidationTrait.php : 70

Will only validate international numbers if the code is provided, otherwise, will validate local only

`public asInternationalPhone([string|null $code = null ][, string|null $regex = null ][, string|null $message = 'Invalid phone number' ]) : bool|int`

##### Parameters

$code : string|null = null

  International country that you want to check against

$regex : string|null = null

  Your custom regular expression we can depend on instead.

$message : string|null = 'Invalid phone number'

##### Tags

throws
  Exception

##### Return values

bool|int

#### asIp()

ValidationTrait.php : 158
`public asIp([string|null $regex = null ][, string|null $message = 'Invalid IP address' ]) : Validator`

##### Parameters

$regex : string|null = null

  Your custom regular expression we can depend on instead.

$message : string|null = 'Invalid IP address'

##### Tags

throws
  Exception

##### Return values

Validator

#### asMac()

ValidationTrait.php : 173
`public asMac([string|null $regex = null ]) : Validator`

##### Parameters

$regex : string|null = null

  Your custom regular expression we can depend on instead.

##### Tags

throws
  Exception

##### Return values

Validator

#### asNumber()

ValidationTrait.php : 104
`public asNumber([string|null $message = 'Invalid Number' ]) : static`

##### Parameters

$message : string|null = 'Invalid Number'

##### Tags

throws
  Exception

##### Return values

static

#### asNumeric()

ValidationTrait.php : 114
`public asNumeric([string|null $message = 'Invalid Numeric' ]) : static`

##### Parameters

$message : string|null = 'Invalid Numeric'

##### Tags

throws
  Exception

##### Return values

static

#### asNumericInt()

ValidationTrait.php : 124
`public asNumericInt([string|null $message = 'Invalid Numeric Integer' ]) : static`

##### Parameters

$message : string|null = 'Invalid Numeric Integer'

##### Tags

throws
  Exception

##### Return values

static

#### asPassword()

ValidationTrait.php : 95

Validates the rules as follows - At least one integer - At least one lowercase alpha letter - At least one Uppercase alpha letter - At least one special character

`public asPassword([string|null $regex = null ][, string|null $message = 'Week Password' ]) : static`

##### Parameters

$regex : string|null = null

  Your custom regular expression we can depend on instead.

$message : string|null = 'Week Password'

##### Tags

throws
  Exception

##### Return values

static

#### asSlug()

ValidationTrait.php : 211
`public asSlug([string|null $regex = null ]) : Validator`

##### Parameters

$regex : string|null = null

  Your custom regular expression we can depend on instead.

##### Tags

throws
  Exception
example

      $slug = 'fsjkfjshfsjk-skdhfkjdfsj-skdjfhjskdf'; // valid slug
      $slug2 = 'sfksdfsdskljfhsdhjkfhsdsfsdfsfsd'; // valid slug
      $slug3 = 'dkfl ksjfhsdk/skjdfsk%'; // invalid slug

##### Return values

Validator

#### asUrl()

ValidationTrait.php : 139
`public asUrl([string|null $regex = null ][, string|null $message = 'Invalid URL' ]) : Validator`

##### Parameters

$regex : string|null = null

  Your custom regular expression we can depend on instead.

$message : string|null = 'Invalid URL'

##### Tags

throws
  Exception

##### Return values

Validator

#### validate()

Validator.php : 15
`public static validate(string $keyToValidate, Arrayable|null $data) : static`

##### Parameters

$keyToValidate : string
$data : Arrayable|null

##### Return values

static

#### _validate()

ValidationTrait.php : 24

Use this to cover scenarios this contract does not cover

`private _validate(string $regex[, string|null $message = 'Invalid data' ]) : bool|int`

##### Parameters

$regex : string
  - The regular expression to check against
$message : string|null = 'Invalid data'
  - The message to throw if the value is invalid and we are in the exceptions mode

##### Tags

throws
  Exception

##### Return values

bool|int

#### _validateFilter()

ValidationTrait.php : 226

Internal validator based on PHP filter_var validations

`private _validateFilter( $filterType[, string $message = 'Invalid Data' ]) : int|bool`

##### Parameters

$filterType :
$message : string = 'Invalid Data'

##### Tags

throws
  Exception

##### Return values

int|bool

#### getOrFail()

ValidationTrait.php : 37
`private getOrFail() : mixed`

##### Tags

throws
  Exception

#### shouldBe()

ValidationTrait.php : 239
`private shouldBe(mixed $expected[, string|null $message = 'Invalid data' ]) : Validator`

##### Parameters

$expected : mixed
$message : string|null = 'Invalid data'

##### Tags

throws
  Exception

##### Return values

Validator

## Search results