Required Fields

Hello!
Is there any way to make certain fields in a schema mandatory to fill in?

I tried adding:

required: true

to a Quantity in a yaml schema, but I was unable to observe any effects.

Thank you!

Tim, DIFFER

Hi @timal

To my knowledge, required: true has no effect — NOMAD schemas (YAML or Python) currently have no way to mark a field as mandatory, and unrecognized keys are silently ignored rather than flagged. So this isn’t a mistake on your end; the feature simply doesn’t exist.

Two practical workarounds:

  1. Prompt via a default value. Give the quantity a placeholder default such as default: 'please fill in'. The field then shows up pre-filled with that text in the ELN form, which nudges users to replace it. This is purely a visual reminder — nothing stops someone from leaving it as is.

  2. Check the field during processing. With a Python schema (not possible in pure YAML), we can add a validation rule using NOMAD’s @constraint mechanism that checks whether the field was filled in and writes a clear message to the entry’s processing log if not.

Maybe @laurih knows of a better option, or can plan in support?

In the case of support, the question becomes: what should happen when the field is left open? Should saving be blocked entirely, should the entry be saved but flagged with an error, or is a gentle reminder in the form enough?

Best,
Nathan

Thank you for your explanation! For now, option 1 suffices, but I will definitely try option 2 later.
The point you make on the consequence is great. I guess that depends on the level of importance. It would be a useful feature if both of your suggestions would be options e.g. warning: true gives the error flag and required: true blocks the saving both with a message urging the user to fill in a value.