@Override
    public String validate(Mercadoria m) {
        StringBuilder sb = new StringBuilder();
        if (m != null) {
            javax.validation.Validator validator = factory.getValidator();
            Set<ConstraintViolation<Mercadoria>> constraintViolations = validator.validate(m);

            if (!constraintViolations.isEmpty()) {
                sb.append("Validação da entidade Mercadoria\n");
                for (ConstraintViolation<Mercadoria> constraint : constraintViolations) {
                    sb.append(String.format("%n%s: %s", constraint.getPropertyPath(), constraint.getMessage()));
                }
            }
        }
        return sb.toString();
    }