I need to add restriction on a particular field - phoneNumber. Rightnow the restriction looks like this :
<xsd:element minOccurs="0" name="phoneNumber">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:pattern value="[0-9]{2}[\-][0-9]{10}"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
So, this would work if the phone number have a value
91-1234567890
But for a US contact I want the country code is one 1. So, the pattern needs to be changed to [0-9]{1}[\-][0-9]{10}
1-1234567890
So, I have two questions
- How do I give a specific range in this pattern.
- Is there a way to decide the pattern during runtime? e.g. If I get the country as India I would keep it as
[0-9]{2}[\-][0-9]{10}
and if I get it as US then I would modify it to[0-9]{1}[\-][0-9]{10}