mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-08-28 10:54:59 +00:00
* working on incorporating regex logic * Implemented a validation check for database name with given rules in doc within controller * fixing tests to pass * reflecting changes to match docs * fixed tests further, hopefully * for sure fixed integration tests, and moved validation check * integration tests passed, go test now will pass * fixed name size to 230 due to previous commit acknowledgement * fixed field test negative validations * added missing comma
61 lines
1.4 KiB
Go
61 lines
1.4 KiB
Go
package schemar
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/featurebasedb/featurebase/v3/dax"
|
|
"github.com/featurebasedb/featurebase/v3/errors"
|
|
)
|
|
|
|
const (
|
|
ErrCodeDatabaseIDInvalid errors.Code = "DatabaseIDInvalid"
|
|
ErrCodeDatabaseNameInvalid errors.Code = "DatabaseNameInvalid"
|
|
|
|
ErrCodeTableIDInvalid errors.Code = "TableIDInvalid"
|
|
ErrCodeTableNameInvalid errors.Code = "TableNameInvalid"
|
|
ErrCodeInvalidPrimaryKey errors.Code = "InvalidPrimaryKey"
|
|
|
|
ErrCodeFieldNameInvalid errors.Code = "FieldNameInvalid"
|
|
)
|
|
|
|
func NewErrDatabaseIDInvalid(databaseID dax.DatabaseID) error {
|
|
return errors.New(
|
|
ErrCodeDatabaseIDInvalid,
|
|
fmt.Sprintf("database ID '%s' is invalid", databaseID),
|
|
)
|
|
}
|
|
|
|
func NewErrDatabaseNameInvalid(databaseName dax.DatabaseName) error {
|
|
return errors.New(
|
|
ErrCodeDatabaseNameInvalid,
|
|
fmt.Sprintf("invalid database name %s", databaseName),
|
|
)
|
|
}
|
|
|
|
func NewErrTableIDInvalid(tableID dax.TableID) error {
|
|
return errors.New(
|
|
ErrCodeTableIDInvalid,
|
|
fmt.Sprintf("table ID '%s' is invalid", tableID),
|
|
)
|
|
}
|
|
|
|
func NewErrTableNameInvalid(tableName dax.TableName) error {
|
|
return errors.New(
|
|
ErrCodeTableNameInvalid,
|
|
fmt.Sprintf("table name '%s' is invalid", tableName),
|
|
)
|
|
}
|
|
|
|
func NewErrInvalidPrimaryKey() error {
|
|
return errors.New(
|
|
ErrCodeInvalidPrimaryKey,
|
|
"invalid primary key",
|
|
)
|
|
}
|
|
|
|
func NewErrFieldNameInvalid(fieldName dax.FieldName) error {
|
|
return errors.New(
|
|
ErrCodeFieldNameInvalid,
|
|
fmt.Sprintf("field name '%s' is invalid", fieldName),
|
|
)
|
|
}
|