flask-resty icon indicating copy to clipboard operation
flask-resty copied to clipboard

Inspect violated constraints

Open taion opened this issue 7 years ago • 3 comments

cc @cancan101 @itajaja

This is obviously very rough and the final API will need to be more flexible, but the basic approach appears to work. Thoughts?

taion avatar Nov 19 '18 15:11 taion

I think one option would be to make this lookup be a set of utility function and then let the writer of the view decide how they want to do the mapping of the pg error to the api error.

cancan101 avatar Nov 19 '18 20:11 cancan101

@sloria since you looked at this – is there an easy way to go from attribute name to data key, given a schema?

taion avatar Mar 27 '20 19:03 taion

I think it'd be

attr_to_data_key = {
    field.attribute or field_name: field.data_key or field_name 
    for field_name, field in schema.fields.items()
}

sloria avatar Mar 27 '20 19:03 sloria