scotthovestadt / schema-object

Enforce schema on JavaScript objects, including type, transformation, and validation. Supports extends, sub-schemas, and arrays.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support custom methods attached to SchemaObject factory

scotthovestadt opened this issue · comments

Moving towards allowing the SchemaObject to replace Models in your code. To do this, need to attach methods to each class.

Example:

const Person = new SchemaObject({
  firstName: String,
  lastName: String
}, {
  methods: {
    getFullName: function() {
      return this.firstName + ' ' + this.lastName;
    }
  }
});