com.blade.validator.Validators.notNull()

Here are the examples of the java api com.blade.validator.Validators.notNull() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

2 Examples 7

13 Source : Validator.java
with MIT License
from biezhi

public static void orderParam(Order order) {
    Validators.notNull().test(order).throwMessage("订单参数缺失");
    Validators.notNull().test(order.getMoney()).throwMessage("订单参数缺失[money]");
    double minAmount = Utils.parseDouble(Bootstrap.getGlobalConfig().get(Constant.AMOUNT_MIN), 0.1D);
    double maxAmount = Utils.parseDouble(Bootstrap.getGlobalConfig().get(Constant.AMOUNT_MAX), 1000D);
    if (order.getMoney().doubleValue() < minAmount) {
        throw new ValidatorException(String.format("金额最小为 %d 元", minAmount));
    }
    if (order.getMoney().doubleValue() > maxAmount) {
        throw new ValidatorException("先生,请不要这样!");
    }
    if (StringKit.isNotEmpty(order.getPayEmail()) && !PatternKit.isEmail(order.getPayEmail())) {
        throw new ValidatorException("错误的邮箱格式");
    }
    Validators.notEmpty().test(order.getPayUser()).throwMessage("订单参数缺失[payUser]");
    Validators.notEmpty().test(order.getPayComment()).throwMessage("订单参数缺失[payComment]");
    Validators.length(1, 50).test(order.getPayUser()).throwMessage("昵称长度仅允许在 1-50 个字符");
    int min = Utils.parseInt(Bootstrap.getGlobalConfig().get(Constant.COMMENT_MIN_SIZE), 4);
    int max = Utils.parseInt(Bootstrap.getGlobalConfig().get(Constant.COMMENT_MAX_SIZE), 500);
    Validators.length(min, max).test(order.getPayComment()).throwMessage(String.format("留言长度仅允许在 %d-%d 个字符", min, max));
    if (EMOJI_PATTERN.matcher(order.getPayUser()).find()) {
        throw new ValidatorException("您的输入中包含了禁止处理的字符 :( 请重新输入");
    }
    if (EMOJI_PATTERN.matcher(order.getPayUser()).find()) {
        throw new ValidatorException("您的输入中包含了禁止处理的字符 :( 请重新输入");
    }
}

9 Source : Validator.java
with MIT License
from biezhi

public static void installParam(InstallParam installParam) {
    Validators.notNull().test(installParam).throwMessage("安装参数缺失");
    Validators.notEmpty().test(installParam.getPlatform()).throwMessage("安装参数缺失[platform]");
    authParam(installParam.getUsername(), installParam.getPreplacedword());
    if (Platform.YOUZAN.toString().equalsIgnoreCase(installParam.getPlatform())) {
        Validators.notEmpty().test(installParam.getYouzanClientId()).throwMessage("ClientID不能为空");
        Validators.notEmpty().test(installParam.getYouzanClientSecret()).throwMessage("ClientSecret不能为空");
        Validators.notEmpty().test(installParam.getYouzanShopId()).throwMessage("ShopId不能为空");
    }
    if (Platform.PAYJS.toString().equalsIgnoreCase(installParam.getPlatform())) {
        Validators.notEmpty().test(installParam.getPayJSMchid()).throwMessage("商户号不能为空");
        Validators.notEmpty().test(installParam.getPayJSSecret()).throwMessage("API 密钥不能为空");
    }
}