Is it possible to confirm the date with XSD in the format MM-DD-YYYY?

Is it possible to specify the date limit of MM-DD-YYYY in the XSD on the element we want to limit?

+3
source share
2 answers

Yes maybe with regex

<xsd:simpleType name="Date">
   <xsd:restriction base="xsd:string">
     <xsd:pattern value="\d{2}-\d{2}-\d{4}"/>
   </xsd:restriction>
</xsd:simpleType>

On the left, of course, you should also check the range. Perhaps you can extend the regex to accept only certain numbers.

+3
source

Yes, with a pattern constraint for the string.

In a machine-readable format, I would recommend using an international standard (which is also your national ANSI X3.30 standard), which is expected to be widely supported and well known.

, , , , .

+1

Source: https://habr.com/ru/post/1760191/


All Articles