Download the PHP package hanneskod/clean without Composer

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

hanneskod/clean

Packagist Version Build Status Quality Score

A clean (as in simple) data cleaner (as in validation tool)

Why?

Sometimes it's necessary to perform complex input validation, and a number of tools exist for this purpose (think Respect\Validation). At other times (arguably most times) built in php functions such as the ctype-family and regular expressions are simply good enough. At these times pulling in a heavy validation library to perform basic tasks can be unnecessarily complex.

Clean acts as a thin wrapper around callables and native php functions, in less than 100 logical lines of code, and allows you to filter and validate user input through a simple and compact fluent interface.

Installation

Clean requires php 7.4 or later and has no userland dependencies.

Usage

Basic usage consists of grouping a set of Rules in an ArrayValidator.

Defining rules

Rules are defined using the pre(), match() and post() methods.

  1. pre() takes any number of callable arguments to act as pre-match filters. Filters take an argument and return it in it's filtered state.
  2. post() takes any number of callable arguments to act as post-match filters. Filters take an argument and return it in it's filtered state.
  3. match() takes any number of callable arguments to act as validators. The callable should take an argument and return true if the argument is valid and false if it is not.

A rule definition might look like this:

Using the regexp matcher

The Rule validator comes with one special case matcher: regexp() to match string input against a posix style regular expression (preg_match()).

Making input optional

Rules may define a default value using the def() method. The default value is used as a replacement for null. This effectively makes the field optional in an ArrayValidator setting.

Specifying custom exception messages

When validation fails an exception is thrown with a generic message describing the error. Each rule may define a custom exception message using the msg() method to fine tune this behaviour.

Ignoring unknown input items

By default unkown intput items triggers exceptions.

Use ignoreUnknown() to switch this functionality off.

Nesting validators

ArrayValidators can be nested as follows:

Inspecting validation results using applyTo()

The validate() method throws an exception as soon as a match fails. This may of course not always be what you want. You can inspect the validation result directly by using the applyTo() method instead.

Catching all of the failures

Individual errors can be accessed using the result object.

Identifying a failing rule

Implementing custom validators


All versions of clean with dependencies

PHP Build Version
Package Version
Requires php Version >=7.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 hanneskod/clean contains the following files

Loading the files please wait ....