/*
|
* 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;
|
}
|
}
|