metacatui icon indicating copy to clipboard operation
metacatui copied to clipboard

If an EML configured require field is not an empty array the field will alway raise an error

Open vchendrix opened this issue 1 year ago • 0 comments

We have a case on the Wildland Fire Science Initiative data portal (wfsi-data.org) where we added a sub view to the eml view which adds a project field. If I mark that field as required in the config.js, it always comes up as missing in the validation errors.

A look at the code shows that if the field is validated by the following line of code in EML211#validate it will always return an error if it is not an empty array. This is never seen for string fields (like title) because strings have length too.

I suggest changing the logic to take this into consideration. Maybe checking if it is an array (e.g Array.isArray(this.get(field)) and then checking if it is empty)

https://github.com/NCEAS/metacatui/blob/758ff8e3710637d9fdf406a9c2383e56ff5be877/src/js/models/metadata/eml211/EML211.js#L1652-L1655

vchendrix avatar Jan 19 '24 18:01 vchendrix