I want to validate string and number. If I expect to receive an only string from JSON and receive a number I will return a message with an error. With number the same. Can I find annotation for this? Example @String - if I send a request from the postman without "example" and only 1 (only number)
public class User {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
//Example @String
@Column(name = "password")
private String password;
@Column(name = "role")
private String name;
}
I create a field String in an entity. If I send from Postman 1 without "" - it isn`t correct. But if I send "1" - it correct. How it validate? Vice versa with numbers...
I use string field, but if I send without "" - it also correct. It should be correct only with "".
How can I fix it?
From postman: