package com.sys.bus.sys.validator;

import com.jfinal.core.Controller;
import com.jfinal.validate.Validator;
import com.sys.bus.sys.model.User;

public class UserValidator  extends Validator{
	protected void validate(Controller controller) {
		validateRequiredString("user.name", "titleMsg", "请输入Name!");
		validateRequiredString("user.age", "contentMsg", "请输入Age!");
	}
	protected void handleError(Controller controller) {
		controller.keepModel(User.class);
		String actionKey = getActionKey();
		if (actionKey.equals("/user/save"))
			controller.render("add.html");
		else if (actionKey.equals("/user/update"))
			controller.render("edit.html");
	}
}
