outmoded / lout

API documentation generator
Other
276 stars 49 forks source link

Question about allowedValues #27

Closed mac- closed 11 years ago

mac- commented 11 years ago

I'm noticing that the allowedValues that are available to the template in the different route params seem to just contain an array of 1 item that appears to be a stringified Array of the allowed values.

My question is, is this intended behavior?

For example, if I have config for a route that looks like this:

{
    path: '/foo/{id}',
    method: 'POST',
    config: {
        handler: function(request, reply) { reply({some:'data'}); },
        validate: {
            payload: {
                id: Hapi.types.String().allow(['one','two','three']).required()
            }
        }
    }
}

Then the allowedValues property of payloadParams on the route object in the template returns this value:

["[ \"one\", \"two\", \"three\" ]"]

instead of:

['one','two','three']

So ultimately, I can't easily loop through each value.

If this was not intentional, I can submit a fix. Thanks!

Marsup commented 11 years ago

Late answer but allow only takes a single parameter, aren't you looking for valid ?

mac- commented 11 years ago

Thanks for the reply! You are definitely right that I should be using valid. Hopefully that resolves the issue I was seeing.