Feature #31277
Schema based validation for arrays
Status: | Resolved | Start date: | 2011-10-25 | |
---|---|---|---|---|
Priority: | Should have | Due date: | ||
Assigned To: | Martin Ficzel | % Done: | 100% |
|
Category: | Validation | |||
Target version: | TYPO3 Flow Base Distribution - 2.0 beta 1 | |||
PHP Version: | Complexity: | medium | ||
Has patch: | No |
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
Associated revisions
[FEATURE] Configuration validation through (adapted) JSON Schema
Implementation of a PHP array schema validator modeled using the
JSON Schema specification as guideline.
The following CLI commands which utilize the validator are provided:
- configuration:validate validates the configuration of a certain type
with respect to the provided schemata. The schema files are searched
for in Resources/Private/Schema of all active packages.
- configuration:generateschema is a kickstarter which generates a basic
schema to be used as a starting point for further adjustments
Furthermore, this change includes schemata for all FLOW3 settings and the other
configuration types (Caches, Objects, Policy and Routes).
Change-Id: I542144f9af22c87a5d7712eaba85c453f736838d
Resolves: #31277
Releases: 1.1, 1.2
[FEATURE] Configuration validation through (adapted) JSON Schema
Implementation of a PHP array schema validator modeled using the
JSON Schema specification as guideline.
The following CLI commands which utilize the validator are provided:
- configuration:validate validates the configuration of a certain type
with respect to the provided schemata. The schema files are searched
for in Resources/Private/Schema of all active packages.
- configuration:generateschema is a kickstarter which generates a basic
schema to be used as a starting point for further adjustments
Furthermore, this change includes schemata for all FLOW3 settings and the other
configuration types (Caches, Objects, Policy and Routes).
Change-Id: I542144f9af22c87a5d7712eaba85c453f736838d
Resolves: #31277
Releases: 1.1, 1.2
History
#1 Updated by Bastian Waidelich over 3 years ago
- Assigned To set to Rens Admiraal
#2 Updated by Sebastian Kurfuerst over 3 years ago
Rens wants to implement this :) Sebastian will be around for questions.
#3 Updated by Rens Admiraal over 3 years ago
- Assigned To changed from Rens Admiraal to Thomas Hempel
#4 Updated by Karsten Dambekalns over 3 years ago
- Status changed from New to Accepted
#5 Updated by Martin Ficzel about 3 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 3 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 3 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 3 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 3 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 3 years ago
- Assigned To changed from Thomas Hempel to Martin Ficzel
#11 Updated by Karsten Dambekalns about 3 years ago
- Target version set to 2.0 beta 1
#12 Updated by Gerrit Code Review about 3 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 3 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 3 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 3 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 3 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 3 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 3 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 3 years ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset 1c8a80de60bff7ad0f878ade7e1cedc0f28ee365.
#20 Updated by Gerrit Code Review about 3 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 3 years ago
- Status changed from Under Review to Resolved
Applied in changeset 37145b1f83e3828095f2b584ecc02a0eed3cb551.