Feature #31277

Schema based validation for arrays

Added by Bastian Waidelich almost 10 years ago. Updated about 9 years ago.

Status:
Resolved
Priority:
Should have
Assignee:
Category:
Validation
Start date:
2011-10-25
Due date:
% Done:

100%

Estimated time:
PHP Version:
Has patch:
No
Complexity:
medium

Description

As discussed on the last Code Sprint, some schema based validation similar to
http://json-schema.org/ for arrays would be very useful for FLOW3.

Goal

The JSON schema should be used to verify the syntax of:

  • Settings
  • Routes
  • Image Processing Instructions
  • Content Type Definitions
  • Security Settings

Currently a typo in those sometimes leads to very confusing effects. By validation against a pre-made schema, we can tell the user meaningful errors. We could even integrate that in the exception handling: If an exception happens, we could validate the configuration, as an error in configuration most likely results in exceptions.

Generally, we want to use schemata to validate arrays.

Specification

we should forward-port JSON-schema from http://tools.ietf.org/html/draft-zyp-json-schema-03 to PHP. We are only listing the differences here. We will refer to this work as PHP schema. Some major differences are:

  • JSON schema validation does only distinguish between valid and invalid. We should furthermore have a third, in-between style; something like "Bad smell", which hints to errors. TODO how to implement it?
  • We aim for an implementation of 1. - 5.25 of JSON Schema Draft 03.

3.1. Terminology

For this specification, schema will be used to denote a PHP Schema
definition, and an instance refers to a PHP value that the schema
will be describing and validating.

5.8. dependencies

  • TODO do we need them?

5.20 default

  • We don't need this.

5.23 format

We support the following additional formats:

  • classname: A class name which is known to the object manager // TODO: should it be classname or objectname?

5.26. extends, 5.27 id, 5.28. ref, 5.29 $schema

  • We don't need this.

6 Hyper Schema

  • We don't need this.

Implementation

Implementation-wise, the validator should be split into two parts: One for the implementation of the PHP schema, the second part for the FLOW3-specific additions.

  • We should use \FLOW3\FLOW3\Error\Result
  • the system should be developed test-driven.

Future Work

The schema could even be self-learning to some extend (see https://github.com/kore/XML-Schema-learner for a similar example).


Related issues

Related to TYPO3.ElasticSearch - Bug #37844: Always/Globally check respone for excepted resultNewAdrian Föder2012-06-08

Actions
Has duplicate TYPO3.Flow - Feature #5068: Implement validation for settings (or configuration in general)Resolved2009-10-21

Actions
#1

Updated by Bastian Waidelich over 9 years ago

  • Assignee set to Rens Admiraal
#2

Updated by Sebastian Kurfuerst over 9 years ago

Rens wants to implement this :) Sebastian will be around for questions.

#3

Updated by Rens Admiraal over 9 years ago

  • Assignee changed from Rens Admiraal to Thomas Hempel
#4

Updated by Karsten Dambekalns over 9 years ago

  • Status changed from New to Accepted
#5

Updated by Martin Ficzel about 9 years ago

The development-state of this feature can be seen here https://github.com/mficzel/FLOW3.configurationValidation

#6

Updated by Gerrit Code Review about 9 years ago

  • Status changed from Accepted to Under Review

Patch set 1 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/11858

#7

Updated by Gerrit Code Review about 9 years ago

Patch set 2 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/11858

#8

Updated by Gerrit Code Review about 9 years ago

Patch set 3 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/11858

#9

Updated by Gerrit Code Review about 9 years ago

Patch set 4 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/11858

#10

Updated by Martin Ficzel about 9 years ago

  • Assignee changed from Thomas Hempel to Martin Ficzel
#11

Updated by Karsten Dambekalns about 9 years ago

  • Target version set to 2.0 beta 1
#12

Updated by Gerrit Code Review about 9 years ago

Patch set 5 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/11858

#13

Updated by Gerrit Code Review about 9 years ago

Patch set 6 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/11858

#14

Updated by Gerrit Code Review about 9 years ago

Patch set 7 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/11858

#15

Updated by Gerrit Code Review about 9 years ago

Patch set 8 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/11858

#16

Updated by Gerrit Code Review about 9 years ago

Patch set 9 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/11858

#17

Updated by Gerrit Code Review about 9 years ago

Patch set 10 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/11858

#18

Updated by Gerrit Code Review about 9 years ago

Patch set 1 for branch FLOW3-1.1 has been pushed to the review server.
It is available at http://review.typo3.org/12159

#19

Updated by Martin Ficzel about 9 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100
#20

Updated by Gerrit Code Review about 9 years ago

  • Status changed from Resolved to Under Review

Patch set 2 for branch FLOW3-1.1 has been pushed to the review server.
It is available at http://review.typo3.org/12159

#21

Updated by Martin Ficzel about 9 years ago

  • Status changed from Under Review to Resolved

Also available in: Atom PDF