Download the PHP package franzose/kontrolio without Composer

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

CI

На русском

Kontrolio: keep your data under control.

Kontrolio is a simple standalone data validation library inspired by Laravel and Symfony and compatible with PHP 8.1+. [ Read on Medium ]

Setting up validator

The best way to set up validator:

Of course, you can use Kontrolio\Validator class directly but then you'll need to provide available validation rules by yourself:

Data here is supposed to be the key-value pairs—attributes and their values:

Validation rules can be set in three different formats:

  1. Laravel-like string
  2. Instances of the class based rules
  3. Callables (closures or callbacks)

You can also mix instances and callables when you set multiple validation rules to a single attribute. Here's a simple example:

When you set validation rules as string, validator will parse it to an ordinary array of rules before applying them to the attribute, so when you write 'some' => 'not_empty|length:5,15', it becomes

It's pretty straightforward but remember that all arguments you pass after semicolon (separating them by commas) become the arguments of the validation rule constructor.

When you set validation rule as callback, internally it is wrapped by special object called Kontrolio\Rules\CallbackRuleWrapper to keep consistency defined by Kontrolio\Rules\RuleInterface interface.

Rule options

Allowing empty value

A single rule validation can be skipped when the validated attribute value is empty. If you feel that you need this option, you instantiate a rule using named constructor allowingEmptyValue() or by calling allowEmptyValue() method on the already existing instance:

Skipping rule validation

When creating a new custom class based rule you might need an option to skip its validation based on some conditions. You can define the behavior using canSkipValidation() method:

Callable rules

Callable rule is nothing more than a closure or function that takes an attribute value and returns either boolean result of the validation or an options array equivalent to options provided by a class based validation rule:

Custom rules

Of course you can create your custom rules. Just remember that each rule must be an instance of Kontrolio\Rules\RuleInterface, implement isValid() method and have an identifier. By default, identifiers are resolved by Kontrolio\Rules\AbstractRule and are based on the rule class name without namespace. However, you can override this behavior if you wish overriding getName() method.

Custom rules can be added eighter via factory or validator itself:

Bypassing attribute's value validation completely

It's not the same as using allowEmptyValue() or canSkipValidation() on a rule. With those you can skip only a rule. But you can also bypass a whole attribute by using Kontrolio\Rules\Core\Sometimes rule. Sometimes tells validator to bypass validation when the value of the attribute is null or empty. That's all. You can prepend Sometimes to the attribute's rules array or use its identifier in a ruleset string:

Stopping validation on the first failure

You can tell the validator to stop validation if any validation error occurs:

Stopping certain attribute's validation on the first failure

Using UntilFirstFailure validation rule, you can also stop validation of a single attribute while keeping validation as a whole:

Now when attr fail with NotBlank rule, its validation will be stopped and validator will proceed to the attr2.

Error messages and rule violations

Error messages has a single simple format you'll love:

Every message key can have three segments separated by dot. They are:

  1. Attribute name
  2. Validation rule identifier
  3. Validation rule violation

With these options you can customize messages from the most general to the most specific. Each violation is set by the rule validating the attribute value. So when writing your own validation rule you may provide your own violations to provide customizability of the validation result and error messages.


All versions of kontrolio with dependencies

PHP Build Version
Package Version
Requires 0 Version __unset
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 franzose/kontrolio contains the following files

Loading the files please wait ....