Kenmegne
7 days ago 494d349fb67be74da49caae2794fda702f595fb4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/*
 * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
 * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
 */
package com.megatim.fdxgenerator.annotations;
 
import com.megatim.fdxgenerator.enums.TypeDonnee;
import com.megatim.fdxgenerator.model.StructureLigne;
import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
 
/**
 *
 * @author STEPHANIE
 */
public class TailleFormatDateValidator implements  ConstraintValidator<TailleFormatDateConstraint, StructureLigne> {
    @Override
    public void initialize(TailleFormatDateConstraint cons) {
    }
 
    @Override
    public boolean isValid(StructureLigne structLigne, ConstraintValidatorContext cxt) {
        
         if(structLigne.getTypeDonnee() != null && structLigne.getTypeDonnee().getValue().equals(TypeDonnee.DATE.getValue())) {
             System.out.println("formatDate = "+structLigne.getFormatDate());
             return  structLigne.getFormatDate() != null &&
              structLigne.getTaille() == structLigne.getFormatDate().length();
         } else return true;
    }
}