WeatherValidator.java 文件源码

java
阅读 30 收藏 0 点赞 0 评论 0

项目:SmartSync 作者:
@Override
public void validate(Object object, Errors errors) {

    WeatherLocationDTO weatherLocationDTO = (WeatherLocationDTO) object;

    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "userId", "field.required",
            "User Id must not be empty");

    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "city", "field.required",
            "City must not be empty");
    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "state", "field.required",
            "State must not be empty");

    if(!errors.hasErrors()) {
        if(weatherLocationDTO.getState().length() != 2) {
            errors.rejectValue("state", "filed.invalid",
                    "State must be length 2. Did you forget to use state code?");
        }

    }


}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号