Download the PHP package ianaleck/guard without Composer

On this page you can find all versions of the php package ianaleck/guard. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package guard

guard

Guard is an easy to use, highly customisable PHP validator.

Installing

Install using Composer.

composer require ianaleck/guard

Basic usage

Adding custom rules

Adding custom rules is simple. If the closure returns false, the rule fails.

Adding custom error messages

You can add rule messages, or field messages for total flexibility.

Adding a rule message

Adding rule messages in bulk

Adding a field message

Any field messages you add are used before any default or custom rule messages.

Adding field messages in bulk

Using Field Aliases

Field Aliases helps you format any error messages without showing weird form names or the need to create a custom error.

Extending Guard

You can extend the Guard class to add custom rules, rule messages and field messages. This way, you can keep a tidy class to handle custom validation if you have any dependencies, like a database connection or language files.

Rules

This list of rules are in progress. Of course, you can always contribute to the project if you'd like to add more to the base ruleset.

alnum

If the value is alphanumeric.

alnumDash

If the value is alphanumeric. Dashes and underscores are permitted.

alpha

If the value is alphabetic letters only.

alphaDash

If the value is alphabetic letters only. Dashes and underscores are permitted.

array

If the value is an array.

between(int, int)

Checks if the value is within the intervals defined. This check is inclusive, so 5 is between 5 and 10.

bool

If the value is a boolean.

email

If the value is a valid email.

int

If the value is an integer, including numbers within strings. 1 and '1' are both classed as integers.

number

If the value is a number, including numbers within strings.

Numeric strings consist of optional sign, any number of digits, optional decimal part and optional exponential part. Thus +0123.45e6 is a valid numeric value. Hexadecimal (e.g. 0xf4c3b00c), Binary (e.g. 0b10100111001), Octal (e.g. 0777) notation is allowed too but only without sign, decimal and exponential part.

ip

If the value is a valid IP address.

min(int, [number])

Check if string length is greater than or equal to given int. To check the size of a number, pass the optional number option.

max(int, [number])

Check if string length is less than or equal to given int. To check the size of a number, pass the optional number option.

required

If the value is present.

url

If the value is formatted as a valid URL.

matches(field)

Checks if one given input matches the other. For example, checking if password matches password_confirm.

date

If the given input is a valid date.

You can validate human readable dates like '25th October 1961' and instances of DateTime. For example:

checked

If a field has been 'checked' or not, meaning it contains one of the following values: 'yes', 'on', '1', 1, true, or 'true'. This can be used for determining if an HTML checkbox has been checked.

regex(expression)

If the given input has a match for the regular expression given.

Contributing

Please file issues under GitHub, or submit a pull request if you'd like to directly contribute.

Running tests

Tests are run with phpunit. Run ./vendor/bin/phpunit to run tests.

Note: This package is under heavy development and is not recommended for production.


All versions of guard with dependencies

PHP Build Version
Package Version
Requires php Version >=5.4
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package ianaleck/guard contains the following files

Loading the files please wait ....