Avro Schema Data Validations with Regular Expressions in Java

697 Views Asked by At

I'm very new to Using AVRO Schema and I have a use case where I need to validate AVRO schema data with regular expressions. I mean the field value can allow Numbers OR only allow Alphabets OR AlphaNumeric values OR fixed min-max length etc. I tried like below but it's not working. if any idea please assist me for the same .

AVRO schema is :

{ "type": "record",

"name": "Employee",

"namespace": "com.test.avro",

"fields": [

{
  "name": "empId",
  "type": "string",
  "pattern": "[1-9]"
},

{
  "name": "empName",
  "type": "string",
  "pattern": "[a-zA-Z]"
},

{
  "name": "createdDate",
  "type": "string",
  "pattern": "^[1-9]$"
},

{
   "name": "mobile",
   "type": "string",
  "pattern": "^[1-9]*$"
}

] }

Thanks in Advance.

0

There are 0 best solutions below