title: How to define Enum in JSON schema?
body: <p>I declared <code>Enum</code> in <code>JSON</code> schema as below. I have generated artifacts using schema without any issues. </p>
  
  <p>Currently, I am working on validation part using <code>com.github.fge.jsonschema.* api</code>.
  But during validation, the API is not validating when i submit <code>JSON</code> request without <code>sourceType</code>  element . Need help to resolve the validation error.</p>
  
  <p><em>Note</em>: Schema version is V4</p>
  
  <p><strong>Enum declaration</strong></p>
  
  <p>Main Schema </p>
  
  <pre><code>    {
      "$schema": "http://json-schema.org/draft-04/schema#",
      "title": "xxxxxxxxxxxxxxxxxxxxxxx",
      "description": "xxxxxxxxxxxxxxxxxxxxx",
      "type": "object",
      "properties": {
          "requestHeader": {
              "$ref": "resource:/json/RequestHeader.json#/definitions/requestHeader"
          },
          "sourceType": {
              "$ref": "resource:/json/LcBase.json#/definitions/lcBase/properties/sourceType"
          },
          "billingSystem": {
              "$ref": "resource:/json/LcBase.json#/definitions/lcBase/properties/billingSystem"
          },
          "siteId": {
              "$ref": "resource:/json/LcBase.json#/definitions/lcBase/properties/siteId"
          },
          "ocnValue": {
              "$ref": "resource:/json/LcBase.json#/definitions/lcBase/properties/ocnValue"
          },
          "raoValue": {
              "$ref": "resource:/json/LcBase.json#/definitions/lcBase/properties/raoValue"
          },
          "tn": {
              "$ref": "resource:/json/LcBase.json#/definitions/lcBase/properties/tn"
          },
          "actionCode": {
              "$ref": "resource:/json/LcBase.json#/definitions/lcBase/properties/actionCode"
          },
          "serviceClass": {
              "$ref": "resource:/json/LcBase.json#/definitions/lcBase/properties/serviceClass"
          },
          "bnsCode": {
              "$ref": "resource:/json/LcBase.json#/definitions/lcBase/properties/bnsCode"
          },
          "privacyIndicator": {
              "$ref": "resource:/json/LcBase.json#/definitions/lcBase/properties/privacyIndicator"
          },
          "customerName": {
              "$ref": "resource:/json/LcBase.json#/definitions/lcBase/properties/customerName"
          },
          "workOrderNumber": {
              "$ref": "resource:/json/LcBase.json#/definitions/lcBase/properties/workOrderNumber"
          },
          "accountNumber": {
              "$ref": "resource:/json/LcBase.json#/definitions/lcBase/properties/accountNumber"
          },
          "portInFlag": {
              "$ref": "resource:/json/LcBase.json#/definitions/lcBase/properties/portInFlag"
          },
          "sendDate": {
              "$ref": "resource:/json/LcBase.json#/definitions/lcBase/properties/sendDate"
          },
          "transferFromAccountNumber": {
              "$ref": "resource:/json/LcBase.json#/definitions/lcBase/properties/transferFromAccountNumber"
          },
          "transferToAccountNumber": {
              "$ref": "resource:/json/LcBase.json#/definitions/lcBase/properties/transferToAccountNumber"
          },
          "comments": {
              "$ref": "resource:/json/LcBase.json#/definitions/lcBase/properties/comments"
          }
      }
  }
  </code></pre>
  
  <p>SubSchema</p>
  
  <pre><code>{
      "definitions": {
          "lcBase": {
              "type": "object",
              "properties": {
                  "transactionId": {
                      "type": "integer",
                      "minLength": 0,
                      "maxLength": 15
                  },
                  "sourceType": {
                      "type": "string",
                      "enum": [
                          "abc",
                          "xyz"
                      ]
                  },......
  </code></pre>
  
  <hr>
  
  <h2>Java Validator code</h2>
  
  <pre><code>                JsonNode schemaNode = JsonLoader.fromResource(getResource(reqType)); // Root Node .Class
              JsonNode data = JsonLoader.fromString(jsonString);
              JsonSchemaFactory factory = JsonSchemaFactory.byDefault();
              JsonSchema schema = factory.getJsonSchema(schemaNode);
              report = schema.validate(data);
              if (report != null) {
                  Iterator&lt;ProcessingMessage&gt; iter = report.iterator();
                  while (iter.hasNext()) {
                      ProcessingMessage pm = iter.next();
                      stringBuilder.append(pm.getMessage()).append(",\n");
                  }
                  result = report.isSuccess();
              }
  </code></pre>