Skip to content

Commit

Permalink
Merge pull request #20 from Sebobo/feature/defaultvalue-type-validation
Browse files Browse the repository at this point in the history
WIP FEATURE: defaultValue type validation
  • Loading branch information
Sebobo committed May 26, 2023
2 parents 4232405 + 12d3970 commit 53d353f
Show file tree
Hide file tree
Showing 4 changed files with 151 additions and 30 deletions.
14 changes: 14 additions & 0 deletions .editorconfig
@@ -0,0 +1,14 @@
root = true

[*]
indent_style = space
indent_size = 4
tab_width = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.yaml]
indent_size = 2
tab_width = 2
157 changes: 131 additions & 26 deletions NodeTypes.Schema.json
Expand Up @@ -1078,9 +1078,11 @@
},
"nodeTemplateChildNode": {
"type": "object",
"allOf": [{
"$ref": "#/definitions/nodeTemplate"
}],
"allOf": [
{
"$ref": "#/definitions/nodeTemplate"
}
],
"properties": {
"type": {
"type": "string"
Expand All @@ -1090,6 +1092,122 @@
"type": "string"
}
}
},
"defaultValueType": {
"if": {
"required": ["type"],
"properties": {
"type": {
"minLength": 1
}
}
},
"then": {
"allOf": [
{
"if": {
"properties": {
"type": {
"const": "string"
}
}
},
"then": {
"properties": {
"defaultValue": {
"type": "string"
}
}
}
},
{
"if": {
"properties": {
"type": {
"const": "integer"
}
}
},
"then": {
"properties": {
"defaultValue": {
"type": "integer"
}
}
}
},
{
"if": {
"properties": {
"type": {
"const": "boolean"
}
}
},
"then": {
"properties": {
"defaultValue": {
"type": "boolean"
}
}
}
},
{
"if": {
"properties": {
"type": {
"const": "array"
}
}
},
"then": {
"properties": {
"defaultValue": {
"type": "array"
}
}
}
},
{
"if": {
"properties": {
"type": {
"const": "number"
}
}
},
"then": {
"properties": {
"defaultValue": {
"type": "number"
}
}
}
}
]
}
},
"propertyTypes": {
"anyOf": [
{
"type": "string"
},
{
"enum": [
"string",
"DateTime",
"boolean",
"integer",
"number",
"reference",
"references",
"array",
"Neos\\Media\\Domain\\Model\\Asset",
"array<Neos\\Media\\Domain\\Model\\Asset>",
"Neos\\Media\\Domain\\Model\\ImageInterface"
]
}
]
}
},
"additionalProperties": {
Expand Down Expand Up @@ -1221,25 +1339,7 @@
"additionalProperties": false,
"properties": {
"type": {
"anyOf": [
{
"type": "string"
},
{
"enum": [
"string",
"DateTime",
"boolean",
"integer",
"reference",
"references",
"array",
"Neos\\Media\\Domain\\Model\\Asset",
"array<Neos\\Media\\Domain\\Model\\Asset>",
"Neos\\Media\\Domain\\Model\\ImageInterface"
]
}
]
"$ref": "#/definitions/propertyTypes"
},
"defaultValue": {
"type": [
Expand Down Expand Up @@ -1290,7 +1390,10 @@
"type": "boolean"
},
"inline": {
"type": ["object", "null"],
"type": [
"object",
"null"
],
"properties": {
"editorOptions": {
"$ref": "#/definitions/inlineEditorOptions"
Expand Down Expand Up @@ -1361,7 +1464,8 @@
"validation": {
"$ref": "#/definitions/validation"
}
}
},
"$ref": "#/definitions/defaultValueType"
}
},
"ui": {
Expand Down Expand Up @@ -1409,7 +1513,7 @@
"additionalProperties": false,
"properties": {
"type": {
"type": "string"
"$ref": "#/definitions/propertyTypes"
},
"defaultValue": {
"type": [
Expand Down Expand Up @@ -1439,7 +1543,8 @@
"validation": {
"$ref": "#/definitions/validation"
}
}
},
"$ref": "#/definitions/defaultValueType"
}
}
}
Expand Down
9 changes: 5 additions & 4 deletions examples/NodeTypes.Editors.yaml
Expand Up @@ -13,6 +13,7 @@ My.Vendor:Content.Editors:
placeholder: In the creation dialog
properties:
custom:
defaultValue: 'foo'
ui:
inspector:
editor: 'My/Cool/Editor'
Expand Down Expand Up @@ -107,7 +108,7 @@ My.Vendor:Content.Editors:

assets:
type: array<Neos\Media\Domain\Model\Asset>
defaultValue: []
defaultValue: [ ]
ui:
inspector:
editor: 'Neos.Neos/Inspector/Editors/AssetEditor'
Expand Down Expand Up @@ -138,7 +139,7 @@ My.Vendor:Content.Editors:
editorOptions:
placeholder: i18n
threshold: 2
nodeTypes: [Neos.Neos:Document]
nodeTypes: [ Neos.Neos:Document ]
startingPoint: '/sites'
disabled: false

Expand All @@ -148,7 +149,7 @@ My.Vendor:Content.Editors:
inspector:
editor: 'Neos.Neos/Inspector/Editors/LinkEditor'
editorOptions:
nodeTypes: ['Neos.Neos:Document']
nodeTypes: [ 'Neos.Neos:Document' ]
startingPoint: '/sites'
placeholder: i18n
disabled: false
Expand All @@ -164,7 +165,7 @@ My.Vendor:Content.Editors:
disabled: false
maximumFileSize: null
constraints:
mediaTypes: ['image/jpeg']
mediaTypes: [ 'image/jpeg' ]
features:
crop: true
resize: false
Expand Down
1 change: 1 addition & 0 deletions examples/NodeTypes.Simple.yaml
Expand Up @@ -8,6 +8,7 @@ My.Vendor:Content.Text:
properties:
text:
type: string
defaultValue: 'Some text'
options:
someCustomOption: true
ui:
Expand Down

0 comments on commit 53d353f

Please sign in to comment.