ref 0: internal.checker renamed typecheck (no more internal)
This commit is contained in:
parent
8d45d3241b
commit
16d3399ee9
|
@ -1,8 +1,6 @@
|
|||
package builtin
|
||||
|
||||
import (
|
||||
"git.xdrm.io/go/aicra/internal/checker"
|
||||
)
|
||||
import "git.xdrm.io/go/aicra/typecheck"
|
||||
|
||||
// Any is a permissive type checker
|
||||
type Any struct{}
|
||||
|
@ -13,7 +11,7 @@ func NewAny() *Any {
|
|||
}
|
||||
|
||||
// Checker returns the checker function
|
||||
func (Any) Checker(typeName string) checker.Checker {
|
||||
func (Any) Checker(typeName string) typecheck.Checker {
|
||||
// nothing if type not handled
|
||||
if typeName != "any" {
|
||||
return nil
|
|
@ -1,6 +1,6 @@
|
|||
package builtin
|
||||
|
||||
import "git.xdrm.io/go/aicra/internal/checker"
|
||||
import "git.xdrm.io/go/aicra/typecheck"
|
||||
|
||||
// Bool checks if a value is a boolean
|
||||
type Bool struct{}
|
||||
|
@ -11,7 +11,7 @@ func NewBool() *Bool {
|
|||
}
|
||||
|
||||
// Checker returns the checker function
|
||||
func (Bool) Checker(typeName string) checker.Checker {
|
||||
func (Bool) Checker(typeName string) typecheck.Checker {
|
||||
// nothing if type not handled
|
||||
if typeName != "bool" {
|
||||
return nil
|
|
@ -1,6 +1,6 @@
|
|||
package builtin
|
||||
|
||||
import "git.xdrm.io/go/aicra/internal/checker"
|
||||
import "git.xdrm.io/go/aicra/typecheck"
|
||||
|
||||
// Float64 checks if a value is a float64
|
||||
type Float64 struct{}
|
||||
|
@ -11,7 +11,7 @@ func NewFloat64() *Float64 {
|
|||
}
|
||||
|
||||
// Checker returns the checker function
|
||||
func (Float64) Checker(typeName string) checker.Checker {
|
||||
func (Float64) Checker(typeName string) typecheck.Checker {
|
||||
// nothing if type not handled
|
||||
if typeName != "float64" && typeName != "float" {
|
||||
return nil
|
|
@ -4,7 +4,7 @@ import (
|
|||
"regexp"
|
||||
"strconv"
|
||||
|
||||
"git.xdrm.io/go/aicra/internal/checker"
|
||||
"git.xdrm.io/go/aicra/typecheck"
|
||||
)
|
||||
|
||||
var fixedLengthRegex = regexp.MustCompile(`^string\((\d+))$`)
|
||||
|
@ -19,7 +19,7 @@ func NewString() *String {
|
|||
}
|
||||
|
||||
// Checker returns the checker function. Availables type names are : `string`, `string(length)` and `string(minLength, maxLength)`.
|
||||
func (s String) Checker(typeName string) checker.Checker {
|
||||
func (s String) Checker(typeName string) typecheck.Checker {
|
||||
isSimpleString := typeName == "string"
|
||||
fixedLengthMatches := fixedLengthRegex.FindStringSubmatch(typeName)
|
||||
variableLengthMatches := variableLengthRegex.FindStringSubmatch(typeName)
|
|
@ -1,4 +1,4 @@
|
|||
package checker
|
||||
package typecheck
|
||||
|
||||
// Set of type checkers
|
||||
type Set struct {
|
||||
|
@ -35,9 +35,8 @@ func (s *Set) Run(typeName string, value interface{}) error {
|
|||
// check value
|
||||
if checkerFunc(value) {
|
||||
return nil
|
||||
} else {
|
||||
return ErrDoesNotMatch
|
||||
}
|
||||
return ErrDoesNotMatch
|
||||
}
|
||||
|
||||
return ErrNoMatchingType
|
|
@ -1,4 +1,4 @@
|
|||
package checker
|
||||
package typecheck
|
||||
|
||||
import "errors"
|
||||
|
Loading…
Reference in New Issue