use of org.eweb4j.mvc.config.bean.ValidatorConfigBean in project eweb4j-framework by laiweiwei.
the class ForbidImpl method create.
public ValidatorConfigBean create(String fieldName, ValidatorConfigBean val) {
if (this.ann == null)
return null;
if (val == null || !Validators.FORBID.equals(val.getName())) {
val = new ValidatorConfigBean();
val.setName(Validators.FORBID);
}
FieldConfigBean fcb = new FieldConfigBean();
fcb.setName(fieldName);
fcb.setMessage(CommonUtil.parsePropValue(ann.mess()));
ParamConfigBean pcb = new ParamConfigBean();
pcb.setName(Validators.FORBID_WORD_PARAM);
StringBuilder sb = new StringBuilder();
for (String s : ann.words()) {
if (sb.length() > 0)
sb.append("#");
sb.append(CommonUtil.parsePropValue(s));
}
pcb.setValue(sb.toString());
fcb.getParam().add(pcb);
val.getField().add(fcb);
return val;
}
use of org.eweb4j.mvc.config.bean.ValidatorConfigBean in project eweb4j-framework by laiweiwei.
the class IntImpl method create.
public ValidatorConfigBean create(String fieldName, ValidatorConfigBean val) {
if (this.ann == null)
return null;
if (val == null || !Validators.INT.equals(val.getName())) {
val = new ValidatorConfigBean();
val.setName(Validators.INT);
}
FieldConfigBean fcb = new FieldConfigBean();
fcb.setName(fieldName);
fcb.setMessage(CommonUtil.parsePropValue(ann.mess()));
val.getField().add(fcb);
return val;
}
use of org.eweb4j.mvc.config.bean.ValidatorConfigBean in project eweb4j-framework by laiweiwei.
the class QQImpl method create.
public ValidatorConfigBean create(String fieldName, ValidatorConfigBean val) {
if (this.ann == null)
return null;
if (val == null || !Validators.QQ.equals(val.getName())) {
val = new ValidatorConfigBean();
val.setName(Validators.QQ);
}
FieldConfigBean fcb = new FieldConfigBean();
fcb.setName(fieldName);
fcb.setMessage(CommonUtil.parsePropValue(ann.mess()));
val.getField().add(fcb);
return val;
}
use of org.eweb4j.mvc.config.bean.ValidatorConfigBean in project eweb4j-framework by laiweiwei.
the class RequiredImpl method create.
public ValidatorConfigBean create(String fieldName, ValidatorConfigBean val) {
if (this.ann == null)
return null;
if (val == null || !Validators.REQUIRED.equals(val.getName())) {
val = new ValidatorConfigBean();
val.setName(Validators.REQUIRED);
}
FieldConfigBean fcb = new FieldConfigBean();
fcb.setName(fieldName);
fcb.setMessage(CommonUtil.parsePropValue(ann.mess()));
val.getField().add(fcb);
return val;
}
use of org.eweb4j.mvc.config.bean.ValidatorConfigBean in project eweb4j-framework by laiweiwei.
the class CheckConfigBean method checkMVCValidator.
/**
* Check the Validator part of MVC components configuration
*
* @param rList
* @return
*/
public static String checkMVCValidator(List<ValidatorConfigBean> vList, String beanID, String xmlFile) {
String error = null;
ConfigBean cb = (ConfigBean) SingleBeanCache.get(ConfigBean.class.getName());
if ("true".equals(cb.getMvc().getOpen()) || "1".equals(cb.getMvc().getOpen())) {
if (vList != null && !vList.isEmpty()) {
StringBuilder sb = new StringBuilder();
for (Iterator<ValidatorConfigBean> it = vList.iterator(); it.hasNext(); ) {
ValidatorConfigBean v = it.next();
if (!"".equals(v.getName())) {
if (!Validators.REQUIRED.equalsIgnoreCase(v.getName()) && !Validators.INT.equalsIgnoreCase(v.getName()) && !Validators.EMAIL.equalsIgnoreCase(v.getName()) && !Validators.DATE.equalsIgnoreCase(v.getName()) && !Validators.URL.equalsIgnoreCase(v.getName()) && !Validators.ID_CARD.equalsIgnoreCase(v.getName()) && !Validators.ZIP.equalsIgnoreCase(v.getName()) && !Validators.PHONE.equalsIgnoreCase(v.getName()) && !Validators.QQ.equalsIgnoreCase(v.getName()) && !Validators.IP.equals(v.getName()) && !Validators.CHINESE.equalsIgnoreCase(v.getName()) && !Validators.LENGTH.equalsIgnoreCase(v.getName()) && !Validators.SIZE.equalsIgnoreCase(v.getName()) && !Validators.FORBID.equalsIgnoreCase(v.getName()) && !Validators.ENUM.equalsIgnoreCase(v.getName())) {
sb.append("当前您填写的:( name=").append(v.getName());
sb.append(" )是错误的!它只能填写为:required|int|");
sb.append("email|date|url|idCard|zip|phone|qq|ip|");
sb.append("chinese|length|size|forbid|enum|留空 中的一种 ,忽略大小写 ;\n");
} else if (Validators.SIZE.equalsIgnoreCase(v.getName())) {
int minSize = 0;
for (FieldConfigBean f : v.getField()) {
for (ParamConfigBean p : f.getParam()) {
if (Validators.MIN_SIZE_PARAM.equalsIgnoreCase(p.getName())) {
if (!(p.getValue().matches(RegexList.integer_regexp))) {
sb.append("<param>当前您填写的:( value=").append(p.getValue());
sb.append(" )是错误的!它应该填写为数字");
} else {
minSize = Integer.parseInt(p.getValue());
}
} else if (Validators.MAX_SIZE_PARAM.equalsIgnoreCase(p.getName())) {
if (!(p.getValue().matches(RegexList.integer_regexp))) {
sb.append("<param>当前您填写的:( value=").append(p.getValue());
sb.append(" )是错误的!它应该填写为数字");
} else {
int maxSize = Integer.parseInt(p.getValue());
if (minSize > maxSize) {
sb.append("<param>当前您填写的:( value=").append(p.getValue());
sb.append(" )是错误的!它不能比minSize的值");
sb.append(minSize).append("更小");
}
}
} else {
sb.append("<param>当前您填写的:( name=").append(p.getName());
sb.append(" )是错误的!它只能填写为:minSize|maxSize|");
sb.append("中的一种 ,忽略大小写 ;\n");
}
}
}
} else if (Validators.LENGTH.equalsIgnoreCase(v.getName())) {
int minLength = 0;
for (FieldConfigBean f : v.getField()) {
for (ParamConfigBean p : f.getParam()) {
if (Validators.MIN_LENGTH_PARAM.equalsIgnoreCase(p.getName())) {
if (!(p.getValue().matches(RegexList.integer_regexp))) {
sb.append("<param>当前您填写的:( value=").append(p.getValue());
sb.append(" )是错误的!它应该填写为数字");
} else {
minLength = Integer.parseInt(p.getValue());
}
} else if (Validators.MAX_LENGTH_PARAM.equalsIgnoreCase(p.getName())) {
if (!(p.getValue().matches(RegexList.integer_regexp))) {
sb.append("<param>当前您填写的:( value=").append(p.getValue());
sb.append(" )是错误的!它应该填写为数字");
} else {
int maxLength = Integer.parseInt(p.getValue());
if (minLength > maxLength) {
sb.append("<param>当前您填写的:( value=").append(p.getValue());
sb.append(" )是错误的!它不能比minLength的值");
sb.append(minLength).append("更小");
}
}
} else {
sb.append("<param>当前您填写的:( name=").append(p.getName());
sb.append(" )是错误的!它只能填写为:minLength|maxLength|");
sb.append("中的一种 ,忽略大小写 ;\n");
}
}
}
} else if (Validators.FORBID.equalsIgnoreCase(v.getName())) {
for (FieldConfigBean f : v.getField()) {
for (ParamConfigBean p : f.getParam()) {
if (!Validators.FORBID_WORD_PARAM.equalsIgnoreCase(p.getName())) {
sb.append("<param>当前您填写的:( name=").append(p.getName());
sb.append(" )是错误的!它只能填写为:forbidWord|");
sb.append("忽略大小写 ;\n");
}
}
}
} else if (Validators.ENUM.equalsIgnoreCase(v.getName())) {
for (FieldConfigBean f : v.getField()) {
for (ParamConfigBean p : f.getParam()) {
if (!Validators.ENUM_WORD_PARAM.equalsIgnoreCase(p.getName())) {
sb.append("<param>当前您填写的:( name=").append(p.getName());
sb.append(" )是错误的!它只能填写为:enumWord|");
sb.append("忽略大小写 ;\n");
}
}
}
}
}
if (!"".equals(v.getClazz())) {
try {
if (Thread.currentThread().getContextClassLoader().loadClass(v.getClazz()) == null) {
sb.append("当前您填写的( class=").append(v.getClazz()).append(" )是错误的!它必须是一个有效的类 ;\n");
}
} catch (ClassNotFoundException e) {
sb.append("当前您填写的( class=").append(v.getClazz()).append(" )是错误的!它必须是一个有效的类 ;\n");
}
}
}
if (!"".equals(sb.toString())) {
error = "\n<br /><b>" + xmlFile + "[bean name=" + beanID + "][validator]:</b>\n" + sb.toString();
}
}
}
return error;
}
Aggregations