minLength Constraint is not working as expected in XSD validation

Hi All,

I have created an schema through an xsd.I have set minLength to 1 for a string field of simple type.Whenever i am passing the null value for this field pub.schema.validate service not failing the validation even though this validation error is showing in XML Spy.please let me know if i have missed any thing here.

I am running on IS6.5 SP2

Thanks,
Rajesh

Rajesh,

Does this happen even if the failIfinvalid is set to True. Coz it is by default False?

-Suren

Hi Suren,

Thanks for your reply.I am explicitely handling the isValid variable from the pub.schema.valid service to generate error mail and to log into error tables by setting to false for failIfinvalid.But if the tag value came null, isValid is coming up with true as it should come up with false.

Thanks,
Rajesh

Is the field defined as required? I think minlength=1 applies only if the tag exists and has a value. null is not the same as empty.

Also, there is a server-level setting to control whether or not required fields are enforced. Alas, I do not recall the extended properties name.

Hi Reamon,

Thanks for your inputs.The field i am validating is required.Below the snippet of code which causing the issue.While i have defined in another way like by using simple type then it is giving error as expected. If i am defined simple content in complex type then it is not validating this one.

<xs:element name=“string”>
xs:complexType
xs:simpleContent
<xs:restriction base=“xs:string”>
<xs:minLength value=“1”/>
</xs:restriction>
</xs:simpleContent>
</xs:complexType>
</xs:element>

Thanks,
Rajesh

try one or both of this attributes:

… nillable=“false” …

and/or

… minOccur or minOccurs = “1” …