Syboos Commons BeanUtils validators - ValidateRegex

2010/04/12 17:40Update
TAGS: BeanUtils | Validator | ValidateRegex | RegexValidator

ValidateRegex annotation and RegexValidator class.

■ValidateRegex Annotation
◇ Class Name: com.syboos.beanutils.annotation.ValidateRegex
◇ Validator Class: com.syboos.beanutils.validator.RegexValidator
◇ Properties:
  1. message [optional] error message or error message key.
  2. when    [optional] timing or a condition for validation.
  3. regex  regular express pattern

◇ Usage:
By annotation
    @ValidateRegex(regex="[0-9a-zA-z]*")
    private String value;

    public String getValue() {
        return value;
    }
    public void setValue(String value) {
        this.value = value;
    }


    @ValidateRegex(when="login", message="value is must number or English alphabet.", regex="[0-9a-zA-z]*")
    private String value;

    ...


By XML
<field name="value">
    <validator class="com.syboos.beanutils.validator.RegexValidator" pattern="[0-9a-zA-z]*" message="value is must number or English alphabet." />
</field>

.

有关作者
Syboos.jp編集長システム設計や開発、保守運営などを行ってます。オープンソース技術に興味があります。

Sponsored Link


Comments

用户名 (required)

Email (will not be published) (required)

URL

Evaluation