是否可以为 URI 参数定义验证(范围、长度)?
Is it possible to define validations (ranges, lengths) for URI parameters?
是否可以为 URI 参数定义验证?
- (即
maxVal
、minVal
、maxLength
等?)
如果不是,是否有任何好的解决方法至少可以记录参数的有效范围?
目前没有专门的参数验证语法。唯一支持的属性是 required/optional 和可能值的枚举。
我认为最好使用 markdown 格式的文本来记录任何进一步的限制。例如:
# Blog Posts [/posts{?limit}]
...
## Retrieve Blog Posts [GET]
Retrieves the list of **ACME Blog** posts.
+ Parameters
+ limit (optional, number)
Maximum number of posts to retrieve. The limit **must** be a positive integer.
+ Response 200
专用语法,这将有利于进一步 "machine" 处理已计划,并且很可能来自已计划的 MSON 验证语法。
是否可以为 URI 参数定义验证?
- (即
maxVal
、minVal
、maxLength
等?)
如果不是,是否有任何好的解决方法至少可以记录参数的有效范围?
目前没有专门的参数验证语法。唯一支持的属性是 required/optional 和可能值的枚举。
我认为最好使用 markdown 格式的文本来记录任何进一步的限制。例如:
# Blog Posts [/posts{?limit}]
...
## Retrieve Blog Posts [GET]
Retrieves the list of **ACME Blog** posts.
+ Parameters
+ limit (optional, number)
Maximum number of posts to retrieve. The limit **must** be a positive integer.
+ Response 200
专用语法,这将有利于进一步 "machine" 处理已计划,并且很可能来自已计划的 MSON 验证语法。