Skip to content

Commit

Permalink
Zones now back in the main regime json using some funky JSON parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
samlown committed Oct 4, 2023
1 parent a00ada0 commit b468d8a
Show file tree
Hide file tree
Showing 19 changed files with 15,952 additions and 15,961 deletions.
14 changes: 7 additions & 7 deletions cbc/code.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ type Code string
type CodeMap map[Key]Code

// Basic code constants.
const (
CodePattern = `^[A-Z0-9]+(\.?[A-Z0-9]+)*$`
CodeMinLength = 1
CodeMaxLength = 24
var (
CodePattern = `^[A-Z0-9]+(\.?[A-Z0-9]+)*$`
CodeMinLength uint64 = 1
CodeMaxLength uint64 = 24
)

var (
Expand All @@ -37,7 +37,7 @@ const CodeEmpty Code = ""
// Validate ensures that the code complies with the expected rules.
func (c Code) Validate() error {
return validation.Validate(string(c),
validation.Length(1, CodeMaxLength),
validation.Length(1, int(CodeMaxLength)),
validation.Match(codeValidationRegexp),
)
}
Expand Down Expand Up @@ -69,8 +69,8 @@ func (Code) JSONSchema() *jsonschema.Schema {
Type: "string",
Pattern: CodePattern,
Title: "Code",
MinLength: CodeMinLength,
MaxLength: CodeMaxLength,
MinLength: &CodeMinLength,
MaxLength: &CodeMaxLength,
Description: "Alphanumerical text identifier with upper-case letters, no whitespace, nor symbols.",
}
}
Expand Down
12 changes: 6 additions & 6 deletions cbc/key.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ var (
KeySeparator = "+"
)

const (
var (
// KeyMinLength defines the minimum key length
KeyMinLength = 1
KeyMinLength uint64 = 1
// KeyMaxLength defines the maximum key length
KeyMaxLength = 64
KeyMaxLength uint64 = 64
)

// KeyEmpty is used when no key is available.
Expand All @@ -40,7 +40,7 @@ const KeyEmpty Key = ""
func (k Key) Validate() error {
return validation.Validate(string(k),
validation.Match(KeyValidationRegexp),
validation.Length(KeyMinLength, KeyMaxLength),
validation.Length(int(KeyMinLength), int(KeyMaxLength)),
)
}

Expand Down Expand Up @@ -121,8 +121,8 @@ func (Key) JSONSchema() *jsonschema.Schema {
Type: "string",
Pattern: KeyPattern,
Title: "Key",
MinLength: KeyMinLength,
MaxLength: KeyMaxLength,
MinLength: &KeyMinLength,
MaxLength: &KeyMaxLength,
Description: "Text identifier to be used instead of a code for a more verbose but readable identifier.",
}
}
Loading

0 comments on commit b468d8a

Please sign in to comment.