Download the PHP package hunomina/data-validator without Composer

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

Json Data Validator

Build Status codecov

Description : Library for data validation based on data schemas

This project is licensed under the terms of the MIT license.

Interfaces and classes

DataType

Allows to encapsulate the data into an object and format it in order to be validated using a DataSchema.

JsonData

JsonData implements DataType.

JsonData::format() uses json_decode() to format json string into php array.


DataRule

Allows to validate [DataType]() based on rule specifications (is the data optional ?, is the data allowed to be...).

JsonRule

JsonRule implement DataRule.

JsonRule can validate :

Type/Check Null Length Pattern Min/Max Enum Date format Empty
String :white_check_mark: :white_check_mark: :white_check_mark: :white_check_mark: :white_check_mark: :white_check_mark:
Character :white_check_mark: :white_check_mark: :white_check_mark:
Number :white_check_mark: :white_check_mark: :white_check_mark:
Integer :white_check_mark: :white_check_mark: :white_check_mark:
Float :white_check_mark: :white_check_mark: :white_check_mark:
Boolean
Typed List :white_check_mark: :white_check_mark: :white_check_mark: :white_check_mark:

DataSchema

DataSchema is the library main class. It allows to validate DataType based on sub-schemas and DataRule.

DataSchema::validate() method allows this validation. If DataSchema::validate() does not validate the DataType it throws an [InvalidDataException]().

JsonSchema

JsonSchema implements DataSchema and validates JsonData using JsonRule.

How it works

See tests for examples

A JsonSchema has a type : object or list.

Objects are composed of rules and "child" schemas if needed.

This is a schema definition :

Schemas are just php arrays passe to JsonSchema::setSchema() method.

This schema is composed of 3 elements :

When a data unit is being validated using this schema by calling the JsonSchema::validate() method, the schema will check recursively if the data respects the rules and the "child" schemas.

If the data has :

This data is valid :

This one is not :

As said earlier, rules can be used to validate length or data pattern.

This schema uses the pattern validation on the name element and the length validation on the geolocation element :

When calling the JsonSchema::validate() method, the schema will recursively check all the rule set and "child" schemas. If one rule or one "child" schema is invalid, JsonSchema::validate() returns false.

The "first level" schema is an object typed schema. It could be changed but is not meant to.

Finally, if a "child" schema is typed as an object, the schema will validate it as described above. If it's typed as a list, the schema will simply check each element of the data as an object type using the given "child" schema.


All versions of data-validator with dependencies

PHP Build Version
Package Version
Requires php Version ^7.4|^8.0
ext-json Version *
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 hunomina/data-validator contains the following files

Loading the files please wait ....