Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

What is the correct pattern to validate such in address field in json schema

How to validate that the "street" should contain only upper case. Though it can contain number and spaces

For example:
should accept below

  • 1 ABC ST
  • 1 ABCST
  • ABCST
  • ABCST 1

should not accept below

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

  • 1 aBC ST
  • 1 ABCSt
  • ABcST
  • abcst 1

>Solution :

You can use a regular expression to constrain a string. In your case it would be something like this.

{
   "type": "string",
   "pattern": "^[ A-Z0-9]+$"
}

You can make the regular expression more advanced to not allow leading and trailing space etc.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading