How to Validate a ENUM attribute for a JSON request
<p>I have a Enum attribute in a class.</p>

<p>private ValueType valueType;</p>

<p>ValueType is a ENUM as below.</p>

<pre><code>public enum ValueType {

    INT, FLOAT, STRING, BOOLEAN, ENUM, DATE, CONSTANT
}
</code></pre>

<p>I have a jason request as below. As you can see in the json request, <code>"valueType": "string"</code> (small s), so, I get the below error. So, how to validate the ENUM attribute? </p>

<pre><code>{
  "payload": {
    "id": "Test_snapshot_1",
    "questionId": "Test_snapshot_1",
    "name": "Test_snapshot",
    "valueType": "string",
    "displayType": "heading1",
    "submitOnChange": true,
    "label": "Thank you!",
    "defaultValue": "Thank you!",
    "minValue": null,
    "maxValue": null,
    "minLength": null,
    "maxLength": null,
    "required": null,
    "helpText": null,
    "enumValues": null,
    "answerToOptionalQuestions": null,

  }
}
</code></pre>

<p><strong>ERROR I am Getting as below</strong></p>

<pre><code>{


"status": "BAD_REQUEST",
  "errors": [
    {
      "code": "400",
      "description": "Can not construct instance of com.services.cf.common.dto.ValueType from String value 'string': value not one of declared Enum instance names\n at [Source: org.apache.cxf.transport.http.AbstractHTTPDestination$1@7338f52c; line: 6, column: 28] (through reference chain: com.platform.soa.common.service.wrappers.ServiceRequest[\"payload\"]-&gt;com.services.cf.common.dto.Question[\"valueType\"])",
      "info": "org.codehaus.jackson.map.JsonMappingException: Can not construct instance of com.services.cf.common.dto.ValueType from String value 'string': value not one of declared Enum instance names\\n at [Source: org.apache.cxf.transport.http.AbstractHTTPDestination$1@7338f52c; line: 6, column: 28] (through reference chain: com.platform.soa.common.valueTypeservice.wrappers.ServiceRequest[\\\"payload\\\"]-&gt;com.services.cf.common.dto.Question[\\\"\\\"])\\n\\tat org.codehaus.jackson.map.JsonMappingException.from(JsonMappingException.java:163)\\n\\tat org.codehaus.jackson.map.deser.StdDeserializationContext.weirdStringException(StdDeserializationContext.java:243)\\n",
      "severity": "ERROR",
      "category": "REQUEST",
      "errorIdentifiers": {
        "entry": []
      }
    }
  ],
  "payload": null
}
</code></pre>