class Strings (View source)

Functions useful for validating strings.

Properties

protected Application $app

Methods

__construct(Application $app)

No description

bool
email(string $em, bool $testMXRecord = false, bool $strict = false) deprecated

No description

bool
alphanum(string $value, bool $allowSpaces = false, bool $allowDashes = false)

Returns true on whether the passed string is completely alpha-numeric, if the value is not a string or is an empty string false will be returned.

bool
handle(string $handle)

Returns true if the passed string is a valid "handle" (e.g. only letters, numbers, or a _ symbol).

bool
notempty(string $field)

Returns false if the string is empty (including trim()).

bool
min(string $str, int $length)

Returns true on whether the passed string is larger or equal to the passed length.

bool
max(string $str, int $length)

Returns true on whether the passed is smaller or equal to the passed length.

int
containsNumber(string $str)

Returns 0 if there are no numbers in the string, or returns the number of numbers in the string.

int
containsUpperCase(string $str)

Returns 0 if there are no upper case letters in the string, or returns the number of upper case letters in the string.

int
containsLowerCase(string $str)

Returns 0 if there are no lower case letters in the string, or returns the number of lower case letters in the string.

int
containsSymbol(string $str)

Returns 0 if there are no symbols in the string, or returns the number of symbols in the string.

bool
isValidRegex(string|mixed $pattern, bool $includesDelimiters = true)

Check if a variable contains a valid regular expression.

Details

__construct(Application $app)

No description

Parameters

Application $app

bool email(string $em, bool $testMXRecord = false, bool $strict = false) deprecated

deprecated Use Concrete\Core\Validator\String\EmailValidator

No description

Parameters

string $em
bool $testMXRecord
bool $strict

Return Value

bool

bool alphanum(string $value, bool $allowSpaces = false, bool $allowDashes = false)

Returns true on whether the passed string is completely alpha-numeric, if the value is not a string or is an empty string false will be returned.

Parameters

string $value
bool $allowSpaces

whether or not spaces are permitted in the field contents

bool $allowDashes

whether or not dashes (-) are permitted in the field contents

Return Value

bool

bool handle(string $handle)

Returns true if the passed string is a valid "handle" (e.g. only letters, numbers, or a _ symbol).

Parameters

string $handle

Return Value

bool

bool notempty(string $field)

Returns false if the string is empty (including trim()).

Parameters

string $field

Return Value

bool

bool min(string $str, int $length)

Returns true on whether the passed string is larger or equal to the passed length.

Parameters

string $str
int $length

Return Value

bool

bool max(string $str, int $length)

Returns true on whether the passed is smaller or equal to the passed length.

Parameters

string $str
int $length

Return Value

bool

int containsNumber(string $str)

Returns 0 if there are no numbers in the string, or returns the number of numbers in the string.

Parameters

string $str

Return Value

int

int containsUpperCase(string $str)

Returns 0 if there are no upper case letters in the string, or returns the number of upper case letters in the string.

Parameters

string $str

Return Value

int

int containsLowerCase(string $str)

Returns 0 if there are no lower case letters in the string, or returns the number of lower case letters in the string.

Parameters

string $str

Return Value

int

int containsSymbol(string $str)

Returns 0 if there are no symbols in the string, or returns the number of symbols in the string.

Parameters

string $str

Return Value

int

bool isValidRegex(string|mixed $pattern, bool $includesDelimiters = true)

Check if a variable contains a valid regular expression.

Parameters

string|mixed $pattern

the variable to be checked

bool $includesDelimiters

set to TRUE if $pattern should contain delimiters, FALSE if we need to add them

Return Value

bool