RegEx pattern validation issue in JSON Schema Assertion
search cancel

RegEx pattern validation issue in JSON Schema Assertion

book

Article ID: 271533

calendar_today

Updated On:

Products

CA API Gateway

Issue/Introduction

I am stuck in an regex as well. Below RegEx works at .Net and React JS but not working at API Gateway JSON schema validate assertion Pattern value. Need to sort it out please.

RegEx:  /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/

Schema sample is below for reference:

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "transactionId": {
      "type": "string"
    },

"mail": {
   "type": "string",
          "pattern": "^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$"
    }

}

Environment

Release : 10.1

Resolution

This in my assertion works fine you can test it too.

{
    "type": "object",
    "properties": {
        "progBinaryName": {
            "type": "string",
            "pattern": "^(\\([0-9]{3}\\))?[0-9]{3}-[0-9]{4}$"
        }
    }
}