Page 1 of 1

help with matching invalid dates

Posted: Thu Feb 24, 2005 7:22 pm
by dizziedazz
Can someone help me to create a pattern that identifies "Invalid" dates. Eg. 7/412/02 or 10/1902. Correct dates will be in mm/dd/yy(yy)? format.

Thanks
DzDz

Posted: Fri Feb 25, 2005 12:55 pm
by george
Hi,

Since you are using XML Schema you should check the date built in type and see if you can use that:
http://www.w3.org/TR/xmlschema-2/#date

Otherwise you can constrain the string type for instance like below (or you can invent more strict constraints):

Code: Select all


<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value="\d\d/\d\d/\d\d(\d\d)?"/>
</xs:restriction>
</xs:simpleType>
Best Regards,
George