Home > Blockchain >  XSD validation on multiple phone numbers
XSD validation on multiple phone numbers

Time:11-14

I have this xml: `

<ConsumerPhonenumbers>
<ConsumerPhonenumber>0612345678</ConsumerPhonenumber>
<ConsumerPhonenumber> 312012345678</ConsumerPhonenumber>
</ConsumerPhonenumbers>

` The format of the phone number can be different. Below is alloud 310612345678 or
310612345678 or
31612345678 or
31612345678 or
0612345678 or
06.12345678 or
06-12345678 The number should be min 10 long and max 12 An empty ConsumerPhonenumber is also ok.

Now I have this in my xsd: `

<xs:element name="ConsumerPhonenumber" minOccurs="0" maxOccurs="5" nillable="false">
<xs:simpleType>
  <xs:restriction base="xs:string">
    <xs:pattern value="\ ?\d[\d -]{8,12}\d"></xs:pattern>
  </xs:restriction>
</xs:simpleType>
</xs:element>

`

If I send an empty ConsumerPhonenumber it fails while it should be ok.

Two questions:

  1. Is my pattern value ok?
  2. How to accept empty ConsumerPhonenumber?

Thank you

CodePudding user response:

Thank you LMC for the solution:

\ ?\d[\d -]{8,12}\d|^$
  • Related