talyssonoc / structure

A simple schema/attributes library built on top of modern JavaScript

Home Page:https://structure.js.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Apply other validations over arrays

NotTheRealJoe opened this issue · comments

commented

Feature suggestion: it would be useful to be able to apply the other validations that structure provides over the content of an array.

For example, instead of just itemType: String, being able to use the equal and nullable validations:

const User = attributes({
    roles: {
        type: Array
        item: {
            type: String,
            nullable: false,
            equals: ['reader', 'editor', 'moderator' ... ]
        }
    }
    ...
});