Download the PHP package geraintluff/jsv4 without Composer

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

jsv4-php

A (coercive) JSON Schema v4 Validator for PHP

jsv4-php is a data validator, using version 4 JSON Schemas.

Just include jsv4.php from your code, and use the static methods on the Jsv4 class it defines.

Usage:

Jsv4::validate($data, $schema)

This usage returns an object of the following shape.

The values in the errors array are similar to those for tv4 (a similar project):

The code property corresponds to a constant corresponding to the nature of the validation error, e.g. JSV4_INVALID_TYPE. The names of these constants (and their values) match up exactly with the constants from tv4.

Jsv4::isValid($data, $schema)

If you just want to know the validation status, and don't care what the errors actually are, then this is a more concise way of getting it.

It returns a boolean indicating whether the data correctly followed the schema.

Jsv4::coerce($data, $schema)

Sometimes, the data is not quite the correct shape - but it could be made the correct shape by simple modifications.

If you call Jsv4::coerce($data, $schema), then it will attempt to change the data.

If it is successful, then a modified version of the data can be found in $result->value.

It's not psychic - in fact, it's quite limited. What it currently does is:

Type-coercion for scalar types

Perhaps you are using data from $_GET, so everything's a string, but the schema says certain values should be integers or booleans.

Jsv4::coerce() will attempt to convert strings to numbers/booleans only where the schema says, leaving other numerically-value strings as strings.

Missing properties

Perhaps the API needs a complete object (described using "required" in the schema), but only a partial one was supplied.

Jsv4::coerce() will attempt to insert appropriate values for the missing properties, using a default (if it is defined in a nearby "properties" entry) or by creating a value if it knows the type.

The SchemaStore class

This class represents a collection of schemas. You include it from schema-store.php, and use it like this:

It can handle:

If the schemas being added are "trusted", then an extra argument can be supplied: $store->add($url, $schema, TRUE). In that case, the value of "id" is always believed for all sub-schemas.

A list of "missing" schemas (unresolved "$ref"s) can be retrieved used $store->missing().

This class does not depend on jsv4.php at all - it just deals with raw schema objects. As such, it could (hopefully) be used with other validators with minimal fuss.

Tests

The tests can be run using test.php (from the command-line or via the web).

License

This code is released under a do-anything-you-like "public domain" license (see LICENSE.txt).

It is also released under an MIT-style license (see LICENSE-MIT.txt) because there is sometimes benefit in having a recognised open-source license.


All versions of jsv4 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 geraintluff/jsv4 contains the following files

Loading the files please wait ....