Download the PHP package xphoenyx/valify without Composer

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

NB! This project is archived thus not maintained anymore

Valify

A little framework for user input validation. It is still in development, so keep an eye on commits. Inspired by Yii2 input validation implementation.

Requirements

You need PHP 5.4 to run this code.

Installation

After downloading source, add next code to file, where you data is going to be validated:

Framework uses namespaces, so add next line to the top of file, where validator is called:

There is also a more straightforward way to install this framework through the compser. In your project root, issue next command in terminal:

php composer.phar require xphoenyx/valify 1.*

Now you are ready to validate your data.

Hint for a MVC pattern users

You can implement your own methods in base model class. Please investigate an example below:

Usage

Usage is similar to Yii2 input validation.

Define rules

Each validator accepts message parameter, which should contain an error message as string. You can access attribute name and its value in message by using so-called 'patterns':

NB! If the value is not representable as a string, value type will be shown instead of value itself

You can also implement your own validators by extending valify\validator\AbstractValidator class. In this case, if you are not using composer autoloader, you should also import (require) AbstractValidator. To use own validator in rules, just define validator namespace as a validator name:

Make sure your validator is loaded before defining a namespace in rules. Refer to the valify\validators\ExampleValidator for detailed implementation info.

Define data to be validated

Input data is expected in next format:

Set rules and data

You can call setrules() and loadData() multiple times:

Execute validation

You have an ability to perform a single value validation, without calling setRules() and loadData():

For multiple value validation, pass an array of desired values as a second argument:

validateFor() will return an object with two properties:

Fetch error messages

You can also get an error message of a single attribute:

As each attribute can have a few error messages, getError() will give you the last message of the corresponding attribute error stack (array).

List of built-in validators:

For detailed parameter description of each validator, see class methods in valify/validators.

Testing

In order to properly run unit tests, you need to specify path to the composer autoloader file. Then you just issue the phpunit command in terminal under valify (component root) directory.

Examples

Check index.php in examples directory to view framework in action.

All bug and issue reports are welcome as well as improvement proposals. Enjoy.


All versions of valify with dependencies

PHP Build Version
Package Version
Requires php Version >=5.4.0
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 xphoenyx/valify contains the following files

Loading the files please wait ....