Skip to content
This repository has been archived by the owner on Sep 28, 2022. It is now read-only.

Commit

Permalink
sync validators with the client spec and server
Browse files Browse the repository at this point in the history
  • Loading branch information
yuce committed May 24, 2017
1 parent 37aa539 commit 5a6275c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ Go client for Pilosa high performance distributed bitmap index.

## Change Log

* **v0.3.2**:
* Updated the accepted values for index, frame names and labels to match with the Pilosa server.

* **v0.3.1** (2017-05-01):
* Initial version
* Supports Pilosa Server v0.3.1
Expand Down
6 changes: 3 additions & 3 deletions validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ const (
maxLabel = 64
)

var indexNameRegex = regexp.MustCompile("^[a-z0-9_-]+$")
var frameNameRegex = regexp.MustCompile("^[a-z0-9][.a-z0-9_-]*$")
var labelRegex = regexp.MustCompile("^[a-zA-Z][a-zA-Z0-9_]*$")
var indexNameRegex = regexp.MustCompile("^[a-z][a-z0-9_-]*$")
var frameNameRegex = regexp.MustCompile("^[a-z][a-z0-9_-]*$")
var labelRegex = regexp.MustCompile("^[a-zA-Z][a-zA-Z0-9_-]*$")

// ValidIndexName returns true if the given index name is valid, otherwise false.
func ValidIndexName(name string) bool {
Expand Down
12 changes: 6 additions & 6 deletions validate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import "testing"

func TestValidateIndexName(t *testing.T) {
names := []string{
"a", "ab", "ab1", "1", "_", "-", "b-c", "d_e",
"a", "ab", "ab1", "b-c", "d_e",
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
}
for _, name := range names {
Expand All @@ -48,7 +48,7 @@ func TestValidateIndexName(t *testing.T) {

func TestValidateIndexNameInvalid(t *testing.T) {
names := []string{
"", "'", "^", "/", "\\", "A", "*", "a:b", "valid?no", "yüce",
"", "'", "^", "/", "\\", "A", "*", "a:b", "valid?no", "yüce", "1", "_", "-",
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1",
}
for _, name := range names {
Expand All @@ -60,7 +60,7 @@ func TestValidateIndexNameInvalid(t *testing.T) {

func TestValidateFrameName(t *testing.T) {
names := []string{
"a", "ab", "ab1", "b-c", "d_e", "d.e", "1",
"a", "ab", "ab1", "b-c", "d_e",
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
}
for _, name := range names {
Expand All @@ -72,7 +72,7 @@ func TestValidateFrameName(t *testing.T) {

func TestValidateFrameNameInvalid(t *testing.T) {
names := []string{
"", "'", "^", "/", "\\", "A", "*", "a:b", "valid?no", "yüce", "_", "-", ".data",
"", "'", "^", "/", "\\", "A", "*", "a:b", "valid?no", "yüce", "_", "-", ".data", "d.e", "1",
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1",
}
for _, name := range names {
Expand All @@ -85,7 +85,7 @@ func TestValidateFrameNameInvalid(t *testing.T) {

func TestValidateLabel(t *testing.T) {
labels := []string{
"a", "ab", "ab1", "d_e", "A", "Bc", "B1", "aB",
"a", "ab", "ab1", "d_e", "A", "Bc", "B1", "aB", "b-c",
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
}
for _, label := range labels {
Expand All @@ -97,7 +97,7 @@ func TestValidateLabel(t *testing.T) {

func TestValidateLabelInvalid(t *testing.T) {
labels := []string{
"", "1", "_", "-", "b-c", "'", "^", "/", "\\", "*", "a:b", "valid?no", "yüce",
"", "1", "_", "-", "'", "^", "/", "\\", "*", "a:b", "valid?no", "yüce",
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1",
}
for _, label := range labels {
Expand Down

0 comments on commit 5a6275c

Please sign in to comment.