package cn.superdesk.uniorder.openapi.annotation.impl;

import cn.superdesk.uniorder.openapi.annotation.GreaterThanZero;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

/**
 * @author xc
 * @description
 * @date 2022/4/19 16:35
 */
public class GreaterThanZeroValidator implements ConstraintValidator<GreaterThanZero, Object> {
    @Override
    public boolean isValid(Object o, ConstraintValidatorContext constraintValidatorContext) {
        if (o == null) {
            return false;
        }
        if (o instanceof Number) {
            return ((Number) o).intValue() > 0;
        }

        return false;
    }
}
