Parameter Validation format? #2

Closed
grncdr opened this Issue Apr 15, 2012 · 6 comments

Comments

Projects
None yet
4 participants
Contributor

grncdr commented Apr 15, 2012

In Parameter Validation @zacstewart put forward a format for defining parameter validations inspired by ActiveRecord (correct me if I'm wrong on that one). This looks like it's more fully featured than the JSON schema format I used in the kitchen sink example. In particular, the "exclude" validation can't be expressed with the core JSON schema semantics. What other types of validation are supported by ActiveRecord etc. that would make sense to include in this spec?

Also, do we want to provide some sort of validation information for request bodies? I like the idea of it being an optional thing, where clients can use it if it's present to ensure they aren't sending request bodies that the server will end up rejecting.

Owner

saary commented Apr 15, 2012

Looking at: http://en.wikibooks.org/wiki/Ruby_on_Rails/ActiveRecord/Validations

A few make sense in terms of parameter validation:

  1. numeric
  2. length
  3. range
  4. a general regexp

Also, do we want to provide some sort of validation information for request bodies? I like the idea of it being an optional thing, where clients can use it if it's present to ensure they aren't sending request bodies that the server will end up rejecting.

As for the request/response bodies validation I think a link to a JSON schema is a good way to go without having a large metadata embedded next to the actual API. WDYT?

Contributor

grncdr commented Apr 15, 2012

Definitely agree on having a link to a JSON schema for requests/responses rather than embedding it inline. It also keeps the possibility of providing alternative schemas for other serialization formats open (e.g. a DTD for XML responses).

Section 5 of the JSON Schema RFC lists the standard available validations and definitely covers all of the validations you listed. It's specifically the "exclude" type of validation that isn't covered. For me "exclude" seems less than essential, and the benefits of going with an already developed standard for validations far outweigh it, WDYT @zacstewart ?

Contributor

zacstewart commented Apr 15, 2012

I do like building on an existing standard wherever we can. It does have the inverse of exclude: enum

This provides an enumeration of all possible values that are valid for the instance property.

Request body validation makes me wonder. I'm using JSON payloads in an API instead of request params. This is the way Backbone.js does it by default.

Contributor

grncdr commented Apr 16, 2012

I definitely feel like request body validation should be an optional "nice-to-have" feature, not required to be a compliant implementation.

Owner

hoegertn commented Apr 20, 2012

As this discussion is moving on on the wiki pages I think we can close this issue.

Owner

saary commented Apr 24, 2012

Agreed closing this.

@saary saary closed this Apr 24, 2012

This was referenced May 6, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment