unitaryfund/metriq-api

Include `match` and `unique` field in `userSchema`

Closed this issue · 0 comments

For certain fields in the userSchema inside of userModel.js, we may want to include additional properties to the entities of the schema.

For instance, we may wish to include both unique and match for email in the following manner:

    email: {
        type: String,
        required: true,
        unique: true, 
        match: /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
        index: true
    },

We may also wish to enforce that uniqueness constraint on the username and usernameNormal entities as well.