Subversion Repository Public Repository

litesoft

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package com.temp.shared.validators;

import org.litesoft.core.util.externalization.*;

import com.temp.shared.utils.*;

public class MinMaxLengthValueValidator extends MaxLengthValueValidator {
    public static final String TEMPLATE_ID_CODE_TOO_SHORT = "TooShort";
    public static final String USER_DATA_MIN_LENGTH = "minLength";

    private final int minLength;

    public MinMaxLengthValueValidator( int minLength, int maxLength ) {
        super( maxLength );
        this.minLength = Validate.length( "minLength", minLength );
    }

    @Override
    public E13nData checkValue( Object value ) {
        return super.checkValue( (value instanceof String) ? value : "" );
    }

    @Override
    protected E13nData checkString( String userData ) {
        if ( userData.length() < minLength ) {
            return new E13nData( TEMPLATE_ID_CODE_TOO_SHORT )//
                    .addSubstitutionNamedUserData( USER_DATA_MIN_LENGTH, Integer.toString( minLength ) ) //
                    .addSubstitutionNamedUserData( USER_DATA_CURRENT_LENGTH, Integer.toString( userData.length() ) );
        }
        return super.checkString( userData );
    }
}

Commits for litesoft/trunk/GWT_Sandbox/FormEngine/src/com/temp/shared/validators/MinMaxLengthValueValidator.java

Diff revisions: vs.
Revision Author Commited Message
948 Diff Diff GeorgeS picture GeorgeS Sat 07 Jun, 2014 23:42:39 +0000

Jusefuls Formatter Updated to New Code Format

724 Diff Diff GeorgeS picture GeorgeS Mon 11 Jun, 2012 00:47:26 +0000
600 GeorgeS picture GeorgeS Sun 05 Feb, 2012 18:55:58 +0000

Sync-n