I have DB with the fields name, last name and age. I have a separate enum class with name, e.g. "Alex", "Peter", "Duncan"

I have an API, that changes the name with payload from the request body

```
@RequestMapping(value = "/{userId}/name", method = RequestMethod.PUT)
    @ResponseStatus(HttpStatus.OK)
    public JsonView changeName(@Valid @RequestBody NameDTO nameDTO)
        throws Exception
    {
        _service.changename(getUser(),nameDTO.getName);
        return JsonView.EMPTY_VIEW;
    }

```

My ENUM class

```
public enum Name
{
    ALEX("alex")
    PETER("peter")
    DUNCAN("duncan")
}

```

My NameDTO class

```
public class NameDTO
{
    private String name;

    public NameDTO()
    {
    }

    @JsonProperty("name")
    public String getName()
    {
        return name;
    }

    public void setName(String name)
    {
        this.name = name;
    }

    public NameDTO(String name)
    {
        this.name = name;
    }
}

```

So I want to make some handler, if I will send in JSON in request body something different from my values from ENUM class to get 400 Error

JSON body 

```
    {
       "name": "Alex"
    }

```

GOOD, db updates with this name

```
    {
       "name": "David"
    }

```

Should give 400 (now it gives 500)