ref 0: internal.checker renamed typecheck (no more internal)

This commit is contained in:
Adrien Marquès 2019-05-01 11:28:55 +02:00
parent 8d45d3241b
commit 16d3399ee9
6 changed files with 11 additions and 14 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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)

View File

@ -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

View File

@ -1,4 +1,4 @@
package checker
package typecheck
import "errors"