mac- / ratify

A Hapi plugin for validating the schema of path, query, request body, and response body params using JSON-schema
MIT License
71 stars 27 forks source link

Should query string parameters be converted to the specified type before validating? #21

Closed dschenkelman closed 9 years ago

dschenkelman commented 9 years ago

For example:

"prop": {
  "type": "boolean",
  "description": "true if the user's metadata properties must be included in the returned user, false otherwise.",
}

And validation fails for:

return request.getAsync({
        url: BASE_URL,
        json: true,
        qs: {
          include_metadata: false
        }
      })

Because false is converted to 'false' when the qs is parsed.

mac- commented 9 years ago

This should already be happening, if it's not, then it's a bug.

This is what's intended to run: https://github.com/mac-/ratify/blob/master/lib/RouteSchemaManager.js#L148

dschenkelman commented 9 years ago

Solved :). Was missing type: 'object' in the root object.

mac- commented 9 years ago

:smiley: