Click here to Skip to main content
15,890,527 members
Please Sign up or sign in to vote.
2.33/5 (2 votes)
See more:
Hi,

I would like to validate all urls parameter(pattern validation) in my application.
How to do this, kindly guide me, If you have any idea , please share with me.
It will very helpful for me.
Thanks,
Manuel.

What I have tried:

{
  "$id": "http://example.com/blah/root.json",
  "definitions": {
    "A": {
      "$id": "#foo"
    },
    "B": {
      "$id": "other.json",
      "definitions": {
        "X": {
          "$id": "#bar"
        },
        "Y": {
          "$id": "t/inner.json"
        }
      }
    },
    "C": {
      "$ref": "http://example.com/blah/other.json"
    }
  },
  "properties":{
    "a": { "$ref": "#/definitions/C" }
  }
}  
Posted
Updated 10-Sep-18 3:00am

1 solution

First you need to parse your JSON: take Json.NET (Newtonsoft) [^] for example.

After that you need to build a regular expression to validate your URL: The Perfect URL Regular Expression - URL Regex[^]
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900