title: Jsonschema validate
body: <p>I am working on a Json schema validation and below is the code. I need to have a schema check for element 'pii'.</p>
  <p>The values should only be columns defined in columns (field1,field2 or field3) with a combination of none to all column names.
  The columns names and number of columns are dynamic and differs for every json. Current json example below has 3 columnnames, next may have more.</p>
  <ol>
  <li>How do I add the schema check for pii?</li>
  <li>Is there a better way to validate that the column_names(field1, field2, field3), column_description or column_datatype has a value in it?</li>
  <li>Can I restrict column data type to a set of data types values ['integer','string','object']</li>
  </ol>
  <p>Thanks for your time!</p>
  <pre><code>import json
  import jsonschema
  
  sample_data= {
      &quot;title&quot;: &quot;aaaa.bbbb.cccc&quot;,
      &quot;description&quot;: &quot;customer accounts sample&quot;,
      &quot;owner_email&quot;: &quot;abc.def@xyz.com&quot;,
      &quot;output_type&quot;: &quot;parquet&quot;,
      &quot;version&quot;: &quot;V1.0&quot;,
      &quot;columns&quot;:
      {   &quot;field1&quot;:
          {   &quot;column_description&quot;: &quot;Description for field1&quot;,
              &quot;column_datatype&quot;: &quot;string&quot;
          },
          &quot;field2&quot;:
          {   &quot;column_description&quot;: &quot;Description for field2&quot;,
              &quot;column_datatype&quot;: &quot;string&quot;
          },
          &quot;field3&quot;:
          {   &quot;column_description&quot;: &quot;Description for field3&quot;,
              &quot;column_datatype&quot;: &quot;string&quot;
          }
      },
      &quot;pii&quot;:[&quot;field1&quot;,&quot;field2&quot;]
  }
  
  FileSchema = {
      &quot;definitions&quot;:
      {
          &quot;columnschema&quot;:
          {
              &quot;properties&quot;:
              {
                  &quot;column_description&quot;: { &quot;type&quot; : &quot;string&quot; },
                  &quot;column_datatype&quot;: { &quot;type&quot;: &quot;string&quot; }
              },
              &quot;required&quot;: [&quot;column_description&quot;, &quot;column_datatype&quot;]
          }
      },
  
      &quot;type&quot;: &quot;object&quot;,
      &quot;required&quot;: [ &quot;title&quot;, &quot;description&quot;, &quot;owner_email&quot;, &quot;output_type&quot;, &quot;version&quot;,&quot;columns&quot; ],
      &quot;properties&quot;: 
      {   &quot;title&quot;: {&quot;type&quot;:&quot;string&quot;},
          &quot;description&quot;: {&quot;type&quot;:&quot;string&quot;},
          &quot;owner_email&quot;: {&quot;type&quot;:&quot;string&quot;},
          &quot;output_type&quot;: {&quot;type&quot;:&quot;string&quot;},
          &quot;version&quot;: {&quot;type&quot;:&quot;string&quot;},
          &quot;columns&quot;:
          {
              &quot;type&quot;: &quot;object&quot;,
              &quot;patternProperties&quot;: {
                  &quot;[A-Za-z0-9]&quot; :{ &quot;$ref&quot;: &quot;#/definitions/columnschema&quot; }
                                  }
          }
      }
  }
  
  jsonschema.validate(instance=sample_data, schema=FileSchema)
  
  </code></pre>