I have an endpoint in my spring-boot application which accepts from
& to
ids. Now in my domain, I have following code:
@Data
class UserAccount {
@NotNull
@NotEmpty
private final String from;
@NotNull
@NotEmpty
private final String to;
@JsonCreator
public UserAccount(@JsonProperty("from") String from,
@JsonProperty("to") String to,) {
this.from = from;
this.to = to;
}
}
Is there a way to validate that from
& to
fields should not be same using annotations?