Closed mindaugasnakrosis closed 5 years ago
Is it possible using class-mst to construct ES6 class instance with prop validation?
Example of desired functionality:
const TodoModel = types.model({ name: types.string, }); class TodoClass extends shim(TodoModel) { get name() { return this.name; } set name(name) { this.name = name; } } const Todo = mst(TodoClass, TodoModel), const validInstance = Todo.create({ name: 'todoName' }); // Todo: { name: 'todoName' } const invalidInstance = Todo.create({ name: true }); // Expected error message: "Error while converting `{"name":true}` to `TodoModel`: at path "/name" value `true` is not assignable to type: `string` (Value is not a string)."
@jjrv
Is it possible using class-mst to construct ES6 class instance with prop validation?
Example of desired functionality:
@jjrv