Validator for a required field

Hello there,

this may sound stupid, but I did not find an answer to how I can mark a field in the inspector as required.
What I have is the following (heading property inside a node configuration):

heading:
  type: string
  defaultValue: 'Heading section'
  ui:
    label: i18n
    inlineEditable: TRUE
    reloadIfChanged: TRUE
    inspector:
      group: 'content'
      editor: 'Neos.Neos/Inspector/Editors/TextFieldEditor'
      editorOptions:
        required: TRUE
  validation:
    'Neos.Neos/Validation/NotEmptyValidator': []
    'Neos.Neos/Validation/StringLengthValidator':
      minimum: 1
      maximum: 255

See that I aded both validation and required. This didn’t work. Upon creation of the node I could save it without filling in the heading. As a last resort I added the default value. If you change that the validation is active.

But, can I enforce the field to be required somehow? So that you can’t save the node without it?

Thanks in advance!
Jan

Hi,

The way you’ve done it is the correct way to do it, if it’s not working then maybe the configuration is incorrect in some way.

See https://github.com/neos/neos-development-collection/blob/master/Neos.Neos/Configuration/NodeTypes.yaml#L171-L175 for an example of it in the core.

it’s an inlineEditable property, for those validation doesn’t really work well as we cannot prevent an empty inline editable.

1 Like