Preciso validar uma entidade onde SE um atributo estiver preenchido é obrigatório que os outros 2 estejam também.
Trata-se de dados de conexão a um servidor FTP, se for informado o endereço do FTP então é obrigatório informar também a senha e o nome do usuário (e vice-versa), minha entidade está assim:..
@Length(max = 20, message = "A senha do FTP deve ter no máximo 20 caracteres")
@Column(name = "SENHA_FTP", length = 20)
public String getSenhaFTP() {
return senhaFTP;
}
public void setSenhaFTP(String senhaFTP) {
String oldSenhaFTP = this.senhaFTP;
this.senhaFTP = senhaFTP;
propertyChangeSupport.firePropertyChange(PROP_SENHAFTP, oldSenhaFTP, senhaFTP);
}
@Length(max = 20, message = "O usuário do FTP deve ter no máximo 20 caracteres")
@Column(name = "USUARIO_FTP", length = 20)
public String getUsuarioFTP() {
return usuarioFTP;
}
public void setUsuarioFTP(String usuarioFTP) {
String oldUsuarioFTP = this.usuarioFTP;
this.usuarioFTP = usuarioFTP;
propertyChangeSupport.firePropertyChange(PROP_USUARIOFTP, oldUsuarioFTP, usuarioFTP);
}
@Length(max = 50, message = "O endereço do FTP deve ter no máximo 50 caracteres")
@Column(name = "ENDERECO_FTP", length = 50)
public String getEnderecoFTP() {
return enderecoFTP;
}
public void setEnderecoFTP(String enderecoFTP) {
String oldEnderecoFTP = this.enderecoFTP;
this.enderecoFTP = enderecoFTP;
propertyChangeSupport.firePropertyChange(PROP_ENDERECOFTP, oldEnderecoFTP, enderecoFTP);
}
...