I am using Simple Schema to validate my database entries in a meteor application. I started developing a module to create forms automatically (I know autoform is quite good, but it was not exactly what I needed). To make the radio component I need to know the allowed values for that field, and since it was already specified in the schema I wanted to know if it is possible to retrieve it. Any ideas?
Consider a very simple schema:
s=new SimpleSchema({
list: {
type: String,
allowedValues: ["foo","bar"]
}
});
If you explore the created object you'll find that:
s._schema['list'].allowedValues
returns
["foo", "bar"]
One can deduce the general pattern is:
schemaObject._schema['keyName'].allowedValues