Validate date field in record

I have created a record and I would like to add some constraints. I have a date field and I’m using the “content type” attribute to define it as customized-date with the pattern yyMMdd. When I try to validate a record from the pipeline using this document validation always fails.
Thanks for your help.


Is it a Flatfile documentType or normal XML documentType?

Define a XML Schema(.xsd) which has date validation and create IS doctype using this and validate the against it (pub.schema:validate),insead of manually adding a constraint.


Hi. I have the same problem as well.
I’ve realised that i tried to create a xsd for a large document.
However, this document should be broken down into sub-components, for
easier referencing.
Hence, instead of developing small separate xsds, I’ve created 1 xsd, outlining a few simpleType definition groups to be used by these documents.

<xs:simpleType name=“Tquantity”>
<xs:restriction base=“xs:float”>
<xs:pattern value=“0.00”/>

I created the schema in the developer.
However, I then created a separate document,
with a field called , contentType = ‘Tquantity’

However, in my flow, I did a testing by hardcoding a = 5.32. When i called “pub:schema:validate”, it keeps failing.
ErrorMessage = Value does not match pattern(s)

Could someone help?

Your pattern will only validate values of “0.00” an nothing else. Change the pattern to a regular express like “\d.\d\d” or set the type to xs:decimal and populate the fractionDigits facet or minInclusive and maxInclusive attributes.

One example of a schema snippet that would validate values having no more than two digits to the right of the decimal point between 0 and 999.99 would be:


<?xml version="1.0" encoding="UTF-8"?>

<xs:schema xmlns:xs=“” elementFormDefault=“qualified” attributeFormDefault=“unqualified”>
<xs:element name=“dimensionsQuantity” type=“Tquantity”/>
<xs:simpleType name=“Tquantity”>
<xs:restriction base=“xs:decimal”>
<xs:fractionDigits value=“2”/>
<xs:minInclusive value=“0.00”/>
<xs:maxInclusive value=“999.99”/>

There are many other ways to provide similar functionality in XML schema.


Thanks. That helped.

Hi RMG and All wmusers,
I am trying to do the same thing what the first user in this tred (bert) trying to do i.e. date_cutomized with pattern yyMMdd but getting the error.
Then I was trying the suggestion from RMG to create xsd with date pattern yyMMdd but I came accross follwoing information. Id the below info correct? If correct then what is the way to define a date field in IS Document so that it can be validate using pub.schema:validate function for date patten yyMMdd

XML Schema allows only one date format YYYY-MM-DD. If you
want to validate or use any other format then you have to restrict the token type with a
regular expression,
e.g. date in the format DD-MM-YY:

<xs:simpleType name=“Testdatetype”>
<xs:restriction base=“xs:token”>
<xs:pattern value="[0-9]{2}-[0-9]{2}-[0-9]{2}" />

but above custome date type does not have any date constraint like leap year february should be 29 days etc.