All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.alogic.validator.impl.LengthLimit Maven / Gradle / Ivy

There is a newer version: 1.6.17
Show newest version
package com.alogic.validator.impl;

import com.alogic.validator.Validator;
import com.anysoft.util.Properties;
import com.anysoft.util.PropertiesConstants;

/**
 * 长度限制验证器
 * @author yyduan
 * @since 1.6.12.12 [20181207 duanyy] 
*/ public class LengthLimit extends Validator.Abstract{ protected int from = 1; protected int to = Integer.MAX_VALUE; protected String message = ""; protected String code = "clnt.e2000"; @Override public void configure(Properties p) { super.configure(p); code = PropertiesConstants.getString(p,"code",code,true); message = PropertiesConstants.getString(p,"message","",true); from = PropertiesConstants.getInt(p,"from",from,true); to = PropertiesConstants.getInt(p,"to",to,true); } @Override public boolean check(String value, boolean throwException) { int length = value.length(); return length >= from && length <= to; } @Override public String getMessage() { return message; } @Override public String getCode() { return code; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy