Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Date validation regex is insufficient #319

Closed
JannickWeisshaupt opened this issue Jul 21, 2022 · 3 comments
Closed

Date validation regex is insufficient #319

JannickWeisshaupt opened this issue Jul 21, 2022 · 3 comments
Assignees
Milestone

Comments

@JannickWeisshaupt
Copy link

JannickWeisshaupt commented Jul 21, 2022

The date validation regex for CII (CII-DT-097)
(\d{8})
is insufficient as it only checks that there are at least 8 digits.
For example ab20190101 or 1010101001010101001 is a match.
A better expression would be
^\s*(\d{8})\s*$
which matches exactly 8 digits with only additional white space before and after being allowed.

@MartinForsberg-Ecru
Copy link

This is built into the CII xsd and not a schematron rule so the issue should rather be send to un/cefact who maintains the schemas.

@phax
Copy link
Collaborator

phax commented Jul 21, 2022

Sorry @MartinForsberg-Ecru I tend to disagree here. The CII D16B XSD just contains this:

	<xsd:simpleType name="FormattedDateTimeFormatContentType">
		<xsd:restriction base="xsd:string"/>
	</xsd:simpleType>
	<xsd:complexType name="FormattedDateTimeType">
		<xsd:sequence>
			<xsd:element name="DateTimeString">
				<xsd:complexType>
					<xsd:simpleContent>
						<xsd:extension base="xsd:string">
							<xsd:attribute name="format" type="qdt:FormattedDateTimeFormatContentType"/>
						</xsd:extension>
					</xsd:simpleContent>
				</xsd:complexType>
			</xsd:element>
		</xsd:sequence>
	</xsd:complexType>

whereas the CEN 1.3.8 rules contain this is an explicit rule:

    <rule context="//udt:DateTimeString[@format = '102']">
      <assert id="CII-DT-097" flag="fatal" test="matches(.,'(\d{8})')">[CII-DT-097] - Date time string with format attribute 102 shall be YYYYMMDD.</assert>
    </rule>

@MartinForsberg-Ecru
Copy link

Oops, sorry. I blame the heat :)

@oriol oriol added this to the 1.3.9 milestone Sep 30, 2022
@oriol oriol self-assigned this Sep 30, 2022
@oriol oriol closed this as completed Oct 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants