Skip to content

Commit

Permalink
TASK: Allow custom validation messages for all validators
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebobo committed Jan 16, 2024
1 parent f7c2da9 commit a495790
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 53 deletions.
107 changes: 63 additions & 44 deletions NodeTypes.Schema.json
Expand Up @@ -849,11 +849,17 @@
}
},
"simpleValidator": {
"$comment": "This is the base validator definition for all validators. It is extended by the actual validators below.",
"type": [
"object",
"null"
],
"additionalProperties": false
"properties": {
"validationErrorMessage": {
"type": "string",
"description": "The custom error message to be shown if the validation fails. Neos 8.0+"
}
}
},
"validation": {
"type": [
Expand All @@ -869,24 +875,20 @@
},
"properties": {
"Neos.Neos/Validation/BooleanValidator": {
"type": [
"object",
"null"
],
"$ref": "#/definitions/simpleValidator",
"additionalProperties": false,
"properties": {
"validationErrorMessage": true,
"expectedValue": {
"type": "boolean"
}
}
},
"Neos.Neos/Validation/DateTimeValidator": {
"type": [
"object",
"null"
],
"$ref": "#/definitions/simpleValidator",
"additionalProperties": false,
"properties": {
"validationErrorMessage": true,
"locale": {
"type": "string"
},
Expand All @@ -912,12 +914,10 @@
}
},
"Neos.Neos/Validation/DateTimeRangeValidator": {
"type": [
"object",
"null"
],
"$ref": "#/definitions/simpleValidator",
"additionalProperties": false,
"properties": {
"validationErrorMessage": true,
"earliestDate": {
"type": "string"
},
Expand All @@ -927,12 +927,10 @@
}
},
"Neos.Neos/Validation/EmailAddressValidator": {
"type": [
"object",
"null"
],
"$ref": "#/definitions/simpleValidator",
"additionalProperties": false,
"properties": {
"validationErrorMessage": true,
"strict": {
"type": "boolean"
},
Expand All @@ -942,24 +940,38 @@
}
},
"Neos.Neos/Validation/FloatValidator": {
"$ref": "#/definitions/simpleValidator"
"$ref": "#/definitions/simpleValidator",
"additionalProperties": false,
"properties": {
"validationErrorMessage": true
}
},
"Neos.Neos/Validation/IntegerValidator": {
"$ref": "#/definitions/simpleValidator"
"$ref": "#/definitions/simpleValidator",
"additionalProperties": false,
"properties": {
"validationErrorMessage": true
}
},
"Neos.Neos/Validation/LabelValidator": {
"$ref": "#/definitions/simpleValidator"
"$ref": "#/definitions/simpleValidator",
"additionalProperties": false,
"properties": {
"validationErrorMessage": true
}
},
"Neos.Neos/Validation/LocaleIdentifierValidator": {
"$ref": "#/definitions/simpleValidator"
"$ref": "#/definitions/simpleValidator",
"additionalProperties": false,
"properties": {
"validationErrorMessage": true
}
},
"Neos.Neos/Validation/NumberValidator": {
"type": [
"object",
"null"
],
"$ref": "#/definitions/simpleValidator",
"additionalProperties": false,
"properties": {
"validationErrorMessage": true,
"locale": {
"type": "string"
},
Expand All @@ -985,12 +997,10 @@
}
},
"Neos.Neos/Validation/NumberRangeValidator": {
"type": [
"object",
"null"
],
"$ref": "#/definitions/simpleValidator",
"additionalProperties": false,
"properties": {
"validationErrorMessage": true,
"minimum": {
"type": "integer",
"minimum": 0
Expand All @@ -1002,33 +1012,34 @@
}
},
"Neos.Neos/Validation/NotEmptyValidator": {
"$ref": "#/definitions/simpleValidator"
"$ref": "#/definitions/simpleValidator",
"additionalProperties": false,
"properties": {
"validationErrorMessage": true
}
},
"Neos.Neos/Validation/RegularExpressionValidator": {
"type": [
"object",
"null"
],
"$ref": "#/definitions/simpleValidator",
"additionalProperties": false,
"properties": {
"validationErrorMessage": true,
"regularExpression": {
"type": "string"
},
"validationErrorMessage": {
"type": "string"
}
}
},
"Neos.Neos/Validation/StringValidator": {
"$ref": "#/definitions/simpleValidator"
"$ref": "#/definitions/simpleValidator",
"additionalProperties": false,
"properties": {
"validationErrorMessage": true
}
},
"Neos.Neos/Validation/StringLengthValidator": {
"type": [
"object",
"null"
],
"$ref": "#/definitions/simpleValidator",
"additionalProperties": false,
"properties": {
"validationErrorMessage": true,
"minimum": {
"type": "integer",
"minimum": 0
Expand All @@ -1043,10 +1054,18 @@
}
},
"Neos.Neos/Validation/TextValidator": {
"$ref": "#/definitions/simpleValidator"
"$ref": "#/definitions/simpleValidator",
"additionalProperties": false,
"properties": {
"validationErrorMessage": true
}
},
"Neos.Neos/Validation/UuidValidator": {
"$ref": "#/definitions/simpleValidator"
"$ref": "#/definitions/simpleValidator",
"additionalProperties": false,
"properties": {
"validationErrorMessage": true
}
}
}
},
Expand Down
31 changes: 22 additions & 9 deletions examples/NodeTypes.Validators.yaml
Expand Up @@ -10,40 +10,53 @@ My.Vendor:Content.Validators:
validation:
My.Custom/Validator:
myCustomProperty: true

Neos.Neos/Validation/BooleanValidator:
expectedValue: false
validationErrorMessage: 'Please enter a boolean'
Neos.Neos/Validation/DateTimeValidator:
locale: en
strictMode: false
formatLength: default
formatType: date
validationErrorMessage: 'Please enter a valid datetime'
Neos.Neos/Validation/DateTimeRangeValidator:
earliestDate: 1.1.2000
latestDate: 2.1.2000
validationErrorMessage: 'Please enter a valid datetime in the range of x and y'
Neos.Neos/Validation/EmailAddressValidator:
checkDns: false
strict: false
Neos.Neos/Validation/FloatValidator: { }
Neos.Neos/Validation/IntegerValidator: { }
Neos.Neos/Validation/LabelValidator: { }
Neos.Neos/Validation/LocaleIdentifierValidator: { }
Neos.Neos/Validation/NotEmptyValidator: { }
validationErrorMessage: 'Please enter a valid email address'
Neos.Neos/Validation/FloatValidator:
validationErrorMessage: 'Please enter a valid float'
Neos.Neos/Validation/IntegerValidator:
validationErrorMessage: 'Please enter a valid integer'
Neos.Neos/Validation/LabelValidator:
validationErrorMessage: 'Please enter a valid label'
Neos.Neos/Validation/LocaleIdentifierValidator:
validationErrorMessage: 'Please enter a valid locale'
Neos.Neos/Validation/NotEmptyValidator:
validationErrorMessage: 'Please enter a value'
Neos.Neos/Validation/NumberValidator:
locale: en
strictMode: false
formatLength: default
formatType: decimal
validationErrorMessage: 'Please enter a number'
Neos.Neos/Validation/NumberRangeValidator:
minimum: 0
maximum: 2
Neos.Neos/Validation/RegularExpressionValidator:
regularExpression: '/^[a-z0-9\-]+$/i'
validationErrorMessage: 'Please enter only lowercase letters, numbers or minus'
Neos.Neos/Validation/StringValidator: {}
Neos.Neos/Validation/StringValidator:
validationErrorMessage: 'Please enter a valid string'
Neos.Neos/Validation/StringLengthValidator:
minimum: 0
maximum: 1
ignoreHtml: false
Neos.Neos/Validation/TextValidator: { }
Neos.Neos/Validation/UuidValidator: { }
validationErrorMessage: 'Please enter a valid string between x and y characters'
Neos.Neos/Validation/TextValidator:
validationErrorMessage: 'Please enter a valid text'
Neos.Neos/Validation/UuidValidator:
validationErrorMessage: 'Please enter a valid uuid'

0 comments on commit a495790

Please sign in to comment.