Java tutorial
/* * This file is part of EasyExchange. * * (c) 2014 - Machiel Molenaar <machiel@machiel.me> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ package com.mtech.easyexchange.validator; import com.mtech.easyexchange.model.User; import org.springframework.validation.Errors; import org.springframework.validation.ValidationUtils; import org.springframework.validation.Validator; public class RegistrationValidator implements Validator { @Override public boolean supports(Class<?> clazz) { return User.class.equals(clazz); } @Override public void validate(Object target, Errors errors) { ValidationUtils.rejectIfEmptyOrWhitespace(errors, "email", "email.required"); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "password", "password.required"); } }