Allow dashes as part of the field name.

This commit is contained in:
Joel Leitch 2009-09-29 18:40:08 +00:00
parent e9a2a1d0f7
commit 553a619ebd
2 changed files with 6 additions and 1 deletions

View File

@ -31,7 +31,7 @@ import java.util.regex.Pattern;
*/ */
class JsonFieldNameValidator { class JsonFieldNameValidator {
private static final Pattern JSON_FIELD_NAME_PATTERN = private static final Pattern JSON_FIELD_NAME_PATTERN =
Pattern.compile("(^[a-zA-Z][a-zA-Z0-9\\$_]*$)|(^[\\$_][a-zA-Z][a-zA-Z0-9\\$_]*$)"); Pattern.compile("(^[a-zA-Z][a-zA-Z0-9\\$_\\-]*$)|(^[\\$_][a-zA-Z][a-zA-Z0-9\\$_\\-]*$)");
/** /**

View File

@ -92,4 +92,9 @@ public class JsonFieldNameValidatorTest extends TestCase {
fail("Json field name can not contain a period character"); fail("Json field name can not contain a period character");
} catch (IllegalArgumentException expected) { } } catch (IllegalArgumentException expected) { }
} }
public void testDashesInFieldName() throws Exception {
String fieldName = "test-field-name";
assertEquals(fieldName, validator.validate(fieldName));
}
} }