Download the PHP package cloudonaut/validator without Composer

On this page you can find all versions of the php package cloudonaut/validator. 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 validator

Cloudonaut Validator

This is a simple reusable validator class for PHP.

Installation

Install with composer

Include it into your scripts by using composer autoload and create a new validator object.

Manueal installation

Just copy the Validator.php file from the src folder to your project and include it into your scripts. Than create a new validator object.

Basic usage

The validator stores violations automatically when there is a violation against a rule. To check is a validator has violations you can use the hasViolations() function. To get an array of the violations you can call getViolations(). To add violations you can use one of the many build in check functions or simply add a violation to the list using your own code to check the value.

Example using a build in check isNotEmpty

Check if a value is not empty. If it is empty a violation is added to the validator object.

Output

Example using addViolation

In this example we need the value to match 7 as a simple example. But you can build on this example to do other stuff with value. For example: Call another api and based on the result validate the value, check the value against a database table etc...

output

Example combining rules

You can check the same or other values as many as you want. For example. A e-mail adres must be filled in and a name. But a name is text only.

output

Basic functions

addViolation($msg='')

Adds a violation with the given message

hasViolations()

Checks if the validator has violations. It will return true when there are violations or false when there are no violations.

getViolations()

Returns an array of the messages of all the violations. If there are no violations it just returns an empty array.

Build in checks

All functions will also return true when no violation is added and false when the value violates the rule.

isNotEmpty($value, $msg='')

Adds a violation when the value is empty.

isText($value,$msg='')

Adds a violation when the value is not alphanumeric

isTextOnly($value,$msg='')

Adds a violation when the value is not containing only letters.

isNumber($value,$msg='')

Adds a violation when the value is not a number.

isDigit($value,$msg='')

Adds a violation when the value contains anything else than number characters.

isBetween($min, $max, $value, $msg='')

Adds a violation when the value is not between the min and max value.

isComplex($value,$msg='')

Adds a violation when the value is not containing:

isDate($value,$msg='')

Adds a violation when the value is not a date in the folowing format: yyyy-mm-dd

isTime($value,$msg='')

Adds a violation when the value is not a time indication in the folowing format: hh:mm:ss

isEmail($value,$msg='')

Adds a violation when the value is not an e-mail address

isURL($value,$msg='')

Adds a violation when the value is not an URL.

isIP($value,$msg='')

Adds a violation when the value is not an IP address. (v4)

isFilename($value,$msg='')

Adds a violation when the value is not a filename.

isInList($value,$list, $msg='')

Adds a violation when the value is not a given list.


All versions of validator with dependencies

PHP Build Version
Package Version
No informations.
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 cloudonaut/validator contains the following files

Loading the files please wait ....