cn.ipokerface.common.validation.validator.DigitsConstraintValidator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of common-beans Show documentation
Show all versions of common-beans Show documentation
Common Library of ipokerface
package cn.ipokerface.common.validation.validator;
import cn.ipokerface.common.validation.constraint.Digits;
/**
* Created by PokerFace
* Create Date 2019-11-25.
* Email: [email protected]
* Version 1.0.0
*
* Description:
*/
public class DigitsConstraintValidator implements ConstraintValidator {
public boolean validate(String value, Digits constraintAnnotation) {
if (value == null || "".equals(value)) return true;
try{
Float.parseFloat(value);
return true;
}catch (NumberFormatException e){
}
return false;
}
}