Hacker News new | past | comments | ask | show | jobs | submit login

I don't fully understand the purpose of this



Schematics makes it easy to specify an API interface. It will let you bind / coerce json to your types, and then validate that the provided json bound exactly (no extra fields, no missing required fields, custom validators). We also extended it to provide a polymorphic type that will bind to a class based on a discriminator value in the json (based on an old gist from one of the schematics contributors). The roles definition also allows you to provide different serialized views of a model (though whether the model should be aware of that concern is questionable, but a nice shortcut).

We use schematics to back the data on our domain models. It provides models that are separate from persistence models that live in the data / client layer (database or external service bound), and gives you a few nice things for free (like validation) and you can attach behavior to them.

The only things I would like to see added are:

  - A native polymorphic type (we're going to try and submit a pull request with our implementation within the next month)

  - Roles (lists of fields that are output) optionally separated from the models.

  - Support for redefining a model (currently it is difficult to add a self referencing field and have schematics pick it up for you, or add fields through mixins).




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: