I am using validation-api-1.1.0.Final and hibernate-validator-5.3.6.Final. I would like to do validation for the below case,
Information received from the client,
"BookInfo":[
{
"key":"book.name",
"value":"D12345678"
},
{
"key":"author.phoneNumber",
"value":{
"phone_number":"0123456789",
"numberInfo":{
"contryCode":"44",
"numberRegion":"GB",
"numberType":"MOBILE"
}
}
},
{
"key":"author.email",
"value":"a@b.com"
}
]
Validation rules are specified in the database like below,
"BookInfo":[
{
"key":"name",
"type": "text"
"Validation":{
"pattern":"[a-z,A-Z]"
}
},
{
"key":"author.phoneNumber",
"type": "tel" //It should perform custom validation i have written for phone number validation
"localValidation":{
}
},
{
"key":"author.email",
"type":"email",
"localValidation":{
"pattern": "[*@gmail.com]" //It should perform javax email validation+pattern mentioned here
},
"optional":false
}
]
I would like to perform a validation based on the rule stored in the DB with the payload we have received from the client. I would like to use above 2-library to perform these validations. I am storing the above 2-information in a JAVA bean like below
BookClient.java
public Class BookClient {
private List<Map<String, Object>> bookInfo;
}
BookFromDB.java
public Class BookFromDB {
private List<Map<String, Object>> bookInfo;
}
I have browsed enough and I couldn't get any thread which will perform validation for List It would be great if I get any hint or any other alternative way to perform this validation efficiently.
Any help would be appreciable.