- 浏览: 78198 次
- 性别:
- 来自: 广州
文章分类
最新评论
public class IntegerValidator extends BaseValidator implements GracieValidator { public IntegerValidator() { } public static final String REGEX_INTEGER = "^-?\\d+$"; /** * Validation Rule: Only to accept "-, 0-9" * @param inputText Input string text * @return boolean Return true when input string is only composed by subtraction sign and digits, * otherwise return false. */ public static boolean isInteger(String inputText) { return RegexValidator.isValid(IntegerValidator.REGEX_INTEGER, inputText); } /** * Validation Rule: Only to accept "-, 0-9" * @param inputText Input string text * @param fieldErrorParam Field error tag parameter * @param fieldErrorMessage Field error message * @return boolean Return true when input string is only composed by subtraction sign and digits, * otherwise return false. */ public static boolean isInteger(String inputText, String fieldErrorParam, String fieldErrorMessage) { boolean isValid = IntegerValidator.isInteger(inputText); if (!isValid) { addFieldErrorMessage(fieldErrorParam, fieldErrorMessage); } return isValid; } /** * Validation Rule: Only to accept "-, 0-9" * @param inputText Input string text * @param fieldErrorParam Field error tag parameter * @param bundle Language property file id * @param key Message key * @param defaultMessage Default message * @param arguments The arguments of message * @return boolean Return true when input string is only composed by subtraction sign and digits, * otherwise return false. */ public static boolean isInteger(String inputText, String fieldErrorParam, String bundle, String key, String defaultMessage, String[] arguments) { boolean isValid = IntegerValidator.isInteger(inputText); if (!isValid) { String fieldErrorMessage = MessageUtil.getText(bundle, key, defaultMessage, arguments); addFieldErrorMessage(fieldErrorParam, fieldErrorMessage); } return isValid; } public boolean isValid(String inputText, String fieldErrorParam, String bundle, String key, String defaultMessage, String[] arguments) { return IntegerValidator.isInteger(inputText, fieldErrorParam, bundle, key, defaultMessage, arguments); } public boolean isValid(String inputText, String fieldErrorParam, String fieldErrorMessage) { return IntegerValidator.isInteger(inputText, fieldErrorParam, fieldErrorMessage); } public boolean isValid(String inputText) { return IntegerValidator.isInteger(inputText); } public boolean isValid(String inputText, Object[] objs) { return isValid(inputText); } }
发表评论
-
XssValidator
2012-09-05 10:48 1030public class XssValidator exten ... -
StringLengthValidator
2012-09-05 13:50 815public class StringLengthValida ... -
RegexValidator
2012-09-05 13:50 2143import java.util.regex.Matcher; ... -
PrecisionValidator
2012-09-05 13:51 854public class PrecisionValidator ... -
NumericValidator
2012-09-05 13:51 788public class NumericValidator e ... -
InvalidXMLCharacterValidator
2012-10-05 13:43 841import java.util.regex.Matcher; ... -
InputValidator
2012-10-05 13:43 3125public class InputValidator ext ... -
FloatValidator
2012-10-05 13:42 777public class FloatValidator ext ... -
EmailValidator
2012-10-05 13:43 1109public class EmailValidator ext ... -
DigitValidator
2012-09-04 13:37 849public class DigitValidator ext ... -
DateValidator
2012-09-04 13:36 952import java.text.DateFormat; i ... -
GracieValidator
2012-09-04 13:34 606public interface GracieValidato ... -
AlphanumericValidator
2012-09-04 13:35 656public class AlphanumericValida ... -
MessageUtil
2012-09-04 13:31 1222import java.text.MessageFormat; ... -
FieldValidationConstants
2012-08-31 09:55 722import java.util.Locale; pub ... -
BaseValidator
2012-08-31 09:53 825import org.springframework.web. ... -
Messages
2012-08-31 09:50 727import java.util.ArrayList; im ... -
AlphanumericValidator
2012-08-31 09:48 741public class AlphanumericValida ...
相关推荐
`,然后在`textBox1_Validating`事件中调用验证方法,如`(IntegerValidator)textBox1.Tag).Validate(textBox1.Text)`。 通过这种方式,我们可以轻松地扩展验证框架,添加新的验证规则,只需创建新的验证器类并实现...
2. **NumberValidators**: 这类验证器专注于数字输入,如NumberRangeValidator(验证数值范围)和IntegerValidator(验证整数)。 3. **DateValidators**: 用于日期和时间输入的验证,如DateValidator(验证日期...
4. **IntegerValidator**: 验证输入值是否为有效整数。 5. **RangeValidator**: 检查数值是否在指定范围内。 6. **CreditCardValidator**: 验证信用卡号的格式。 ### 参数说明 每个验证策略通常都有可配置的参数,...
JSF还提供了预定义的验证器,如`LengthValidator`(检查长度)、`IntegerValidator`(检查是否为整数)等。这些验证器可以直接通过标签属性使用。 **三、JSF 转换与验证的组合使用** 在实际应用中,转换和验证经常...
val integerValidator = Validation<Int> { value -> value > 0 && value } ``` 这里,`Validation<Int>`是类型安全的表示,确保我们在验证时只处理整型数据。`{ value -> value > 0 && value 是我们的验证逻辑,...
IntegerValidator 方法列表: 是平等的() isSuperior() isInferior() 在。。。之间() isNegative() isPositive() <?php // Here we check if the integer is equal to number 13 $ validation = \ JB ...