Allow dashes as part of the field name.
This commit is contained in:
parent
e9a2a1d0f7
commit
553a619ebd
|
@ -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\\$_\\-]*$)");
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -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));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user