Skip to content
This repository was archived by the owner on Nov 8, 2024. It is now read-only.
This repository was archived by the owner on Nov 8, 2024. It is now read-only.

Parameter validation unexpected behavior #111

@ecordell

Description

@ecordell

I'm not sure I understand the following behavior in the new parameter validation:

when 'string'
  unless isNaN(Number(String(param['example'])))
    text = "URI parameter '#{paramName}' is declared as 'string' but it is a number."
    result['errors'].push text

In my opinion this should not be an error (or even a warning). If I have declared a parameter as a string in the blueprint, then I mean that it should be a string. Strings are allowed to have only numbers in them. Consider Hex values, for example, which in some cases would parse as a number ('1124'), and in other cases a string ('12FA') - so when I declare it in the blueprint as a string, I mean that it really is a string.

This is somewhat addressed in #106 and #107 but it seems to ignore the case above - if the example value was '12FA' then no error would be thrown - but '1124' is a perfectly valid example of a hex number, and shouldn't be flagged as an error.

The reverse of this makes sense (if I have declared a parameter as a number but it isn't parseable as one, then that's clearly a mistake).

A workaround for now is simply to ensure that any parameters declared as a string don't parse as a number (or pinning Dredd at 0.3.11).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions