⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 signinvalidator.java

📁 Java 敏捷开发--使用Spring Hibernate 和 Eclipse源码
💻 JAVA
字号:
package com.visualpatterns.timex.controller;

import org.springframework.validation.Errors;
import com.visualpatterns.timex.model.Employee;

/**
 * Validator for SignInController
 * @author anil
 * @see com.visualpatterns.timex.controller.SignInController
 */
public class SignInValidator implements
        org.springframework.validation.Validator
{
    public boolean supports(Class clazz)
    {
        return clazz.equals(Employee.class);
    }

    /**
     * Validates an Employee command object. Ensures that employeeId
     * is greater than zero and that a password is specified.
     * @see Employee 
     */
    public void validate(Object command, Errors errors)
    {
        Employee employee = (Employee) command;
        if (employee == null) return;

        int employeeId = employee.getEmployeeId();
        String password = employee.getPassword();

        if (employeeId < 1)
            errors.reject("error.login.invalid");
        else
            if (password == null || password.trim().length() < 8
                    || password.trim().length() > 10)
                errors.reject("error.login.invalid");
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -