Skip to content

overwrite schema setter #220

Open
Open
@MR4online

Description

@MR4online

hi there,

I wonder if there is a way to overwrite the default setter of the schema (I thought I read something like this a while ago).
So, when I have a schema like:

const AppModel = new Schema("app", {
    uuid: { type: "string" },
    name: { type: "string" }
});

I like to have some validation of the "name" in its setter. Lets say something like:

AppModel = {
   setName(value) {
      if (value.length >= 3)
         this.value = value.toLowerCase();
   }
}

I like having the db defition & input validation on one place.

kind regards!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions