我想定义一个可选size
对象。如果对象存在,则应该至少给出一个指定的属性(min
或max
)。我虽然是这样的:
properties:
someval:
type: string
size:
type: object
required: false
additionalProperties: false
minProperties: 1
properties:
min:
required: false
type: string
max:
required: false
type: string
但这似乎minProperies
意味着size
必须可用。如果我只设置最小值或最大值,至少我会收到此验证错误:
<pre>TypeError: Cannot convert undefined or null to object<br> at Function.keys (<anonymous>)<br> at MinProperties.extractValue (C:\mypath\node_modules\raml-typesystem\dist\src\restrictions.js:1059:23)<br> at MinProperties.MinMaxRestriction.check (C:\mypath\node_modules\raml-typesystem\dist\src\restrictions.js:775:22)<br> at C:\mypath\node_modules\raml-typesystem\dist\src\typesystem.js:1564:89<br> at Array.forEach (<anonymous>)<br> at InheritedType.AbstractType.validateDirect (C:\mypath\node_modules\raml-typesystem\dist\src\typesystem.js:1564:37)<br> at InheritedType.AbstractType.validate (C:\mypath\node_modules\raml-typesystem\dist\src\typesystem.js:1612:34)<br> at C:\mypath\node_modules\raml-validate\raml-validate.js:308:31<br> at C:\mypath\node_modules\raml-validate\raml-validate.js:405:18<br> at Array.map (<anonymous>)</pre>
如何在不使用始终设置的size
对象的情况下实现初始规范?