Model or Ember Object property value constraints


#1

Was wondering what patterns people use to enforce that a specific property value falls within a pre defined range and ensures that it never becomes null or undefined. Seems this is the kind of logic that should be in the model.

App.MyModel = Ember.Object.extend({
    name: null,
    option: "A" // only allow to be "A" or "B" as value
});

What is best technique here? Override the setter and raise exception when value is out of bounds? Other ways to enforce the consistency? Use another function to mediate access just never call set directly on the actual property?

Built-in ember techniques?

Code examples welcome.