I've been trying to figure out how to append or include the field types for client side validation in an Angular app that consumes Keystone as an API.
In a basic scenario I get a result like this:
{
"name": "ipad",
"quantity": "200",
"vendor": "apple",
"status": "available"
}
and what I need to get is:
something that tells me that "name" is a string
while "vendor" is a relationship
and "status" is a Select with "x,y,z" options
and that "quantity" is not editable or whatever, just as the model is configured for keystone for this data.
This way I can setup client side forms that can post to the API with some level of automation using Angular directives etc.
My API looks something like this:
Products = keystone.list('Product')
exports.list = (req, res) ->
Products.model.find().exec (err, products) ->
return res.apiError("database error", err) if err
return res.apiError("not found") unless products
res.apiResponse products
Let me know if you have any ideas!
Thanks,
Dustin