首页 > 解决方案 > 最小长度在下面的代码中不起作用。当我为 Name 提供空白值时,它通过了模式验证(它应该抛出错误)

问题描述

最小长度在下面的代码中不起作用。当我为 FirstName 提供空白值时,它会通过 SOAP UI 中的模式验证(它应该抛出错误)。

<xsd:element minOccurs="1" name="FirstName" default="John" >
            <xsd:simpleType>
                <xsd:union>
                    <xsd:simpleType>
                        <xsd:restriction base="xsd:string">
                        <xsd:minLength value="1"/>
                        <xsd:enumeration value="John"/>
                        <xsd:enumeration value="Kyle"/>
                        </xsd:restriction>
                    </xsd:simpleType>
                </xsd:union>
            </xsd:simpleType>
            </xsd:element>

标签: xmlxsdschemasoapuixsd-validation

解决方案


它通过了验证,因为当您为元素提供空值时,有效值是默认值“John”,它对类型有效。


推荐阅读