Menu

## Validator extends KBase
in package

Validator.php : 18

Class for validating various variables.

##### Tags

see
  https://www.kotchasan.com/

### Table of Contents

$cfg : object
  Config class instance.
$request : Request
  Server request class instance.
email() : bool
  Validates an email address.
isImage() : array<string|int, mixed>|bool
  Checks if an uploaded file is an image.

### Properties

#### $cfg

KBase.php : 26

Config class instance.

`protected static object $cfg`

#### $request

KBase.php : 33

Server request class instance.

`protected static Request $request`

### Methods

#### email()

Validator.php : 34

Validates an email address.

`public static email(string $email) : bool`

Returns true if the email format is correct.

##### Parameters

$email : string

##### Tags

assert

  ('admin@localhost.com') [==] true

assert

  ('admin@localhost') [==] true

assert

  ('Abc01.d_e-f@1081009.com') [==] true

assert

  ('ทดสอบ@localhost') [==] false

##### Return values

bool —

#### isImage()

Validator.php : 60

Checks if an uploaded file is an image.

`public static isImage(array<string|int, mixed> $excepts, array<string|int, mixed> $file_upload) : array<string|int, mixed>|bool`

Returns an array [ext, width, height, mime] of the image if it is an image, or false if it is not an image.

##### Parameters

$excepts : array<string|int, mixed>

  Accepted file types, e.g. array('jpg', 'gif', 'png')

$file_upload : array<string|int, mixed>

  Value from $_FILES

##### Tags

assert

  (['gif'], ['name' => 'blank.GIF', 'tmp_name' => ROOT_PATH.'skin/img/blank.gif']) [==] ['ext' => 'gif', 'width' => 1, 'height' => 1, 'mime' => 'image/gif']

##### Return values

array<string|int, mixed>|bool —

## Search results