Is alphabetic, numeric or space


Definition

Return true if a string contain only alphabetic characters or numeric characters: A->Z, a->z, 0->9 or a space character.

Usage

addRule("field -> alpha_num_space")

Tests

@Test
public final void testRuleAlphaNumSpaceOk() throws Exception {
    UtilTest.testIt("alpha_num_space", "123", true);
    UtilTest.testIt("alpha_num_space", "abc123", true);
    UtilTest.testIt("alpha_num_space", "ab c1 23", true);
    UtilTest.testIt("alpha_num_space", "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", true);
    UtilTest.testIt("alpha_num_space", " 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", true);
}

@Test
public final void testRuleAlphaNotNumSpaceOk() throws Exception {
    UtilTest.testIt("alpha_num_space", "!@#$%^&", false);
    UtilTest.testIt("alpha_num_space", "9*123 ", false);
    UtilTest.testIt("alpha_num_space", "abc. ", false);
    UtilTest.testIt("alpha_num_space", "[]", false);
    UtilTest.testIt("alpha_num_space", ".0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", false);
}

results matching ""

    No results matching ""