Task To Accomplish

I am creating a validation service which validates a user profile data for correctness. A user profile can have following information:

  1. Name
  2. Address
  3. Social Security Number(SSN)
  4. Other fields.

When user will submit the profile edit form, I will call the validation service to check if the user entered correct data or not.


  1. Every field is having different method of validation. For eg., To check name, the rule could be to use a regex. To check if address is valid, I might have to call some third party api which will tell if address does actually exist. In general, there could be numerous ways to validate fields.
  2. The profile data has many attributes and is unstructured.

I want to come up with a validation registry component which will be called by validation service to check what is to be done with the field. This component should be generic enough so that it can take up many heterogenous ways to validate certain attributes. I don't want to create if else blocks in my code to create the validation rules.

Things that have come to my mind

  1. Creating registry in yaml : I can write the rules in a yaml file which will tell how to validate an attribute. PFB
 -name: email
  desc: Email address
  type: /entity/Profile/emailaddress
  validation: false
 -name: address
  desc: Home address
  validation: true
    dns: www.xyz.com
    port: 443
    socketTimeout: 30000
    endpoint: /user/{userId}/validateAddress
    mode: sync


I want to explore different ways to implement such system which is generic enough. Please let me know your thoughts on this.

  • What is your requirement exactly? A library that does that validation? If so, also specify on which languages should it work and under what environment, at least.
    – Alejandro
    Feb 19 at 17:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.