field

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 15, 2026 License: Apache-2.0 Imports: 13 Imported by: 44

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Annotation

type Annotation struct {
	// The StructTag option allows overriding the struct-tag
	// of the fields in the generated entity. For example:
	//
	//	field.Annotation{
	//		StructTag: map[string]string{
	//			"id": `json:"id,omitempty" yaml:"-"`,
	//		},
	//	}
	//
	StructTag map[string]string

	// ID defines a multi-field schema identifier. Note,
	// the annotation is valid only for edge schemas.
	//
	//	func (TweetLike) Annotations() []schema.Annotation {
	//		return []schema.Annotation{
	//			field.ID("user_id", "tweet_id"),
	//		}
	//	}
	//
	ID []string
}

Annotation is a builtin schema annotation for configuring the schema fields in codegen.

func ID

func ID(first, second string, fields ...string) *Annotation

ID defines a multi-field schema identifier. Note, the annotation is valid only for edge schemas.

func (TweetLike) Annotations() []schema.Annotation {
	return []schema.Annotation{
		field.ID("user_id", "tweet_id"),
	}
}

func (Annotation) Merge

func (a Annotation) Merge(other schema.Annotation) schema.Annotation

Merge implements the schema.Merger interface.

func (Annotation) Name

func (Annotation) Name() string

Name describes the annotation name.

type BinaryValueScanner

type BinaryValueScanner[T interface {
	encoding.BinaryMarshaler
	encoding.BinaryUnmarshaler
}] struct{}

BinaryValueScanner stores values with encoding.BinaryMarshaler and scans them with encoding.BinaryUnmarshaler.

func (BinaryValueScanner[T]) FromValue

func (BinaryValueScanner[T]) FromValue(value driver.Value) (ret T, err error)

FromValue implements TypeValueScanner.FromValue.

func (BinaryValueScanner[T]) ScanValue

func (BinaryValueScanner[T]) ScanValue() ValueScanner

ScanValue implements TypeValueScanner.ScanValue.

func (BinaryValueScanner[T]) Value

func (BinaryValueScanner[T]) Value(value T) (driver.Value, error)

Value implements TypeValueScanner.Value.

type BoolBuilder added in v0.2.0

type BoolBuilder[T any] struct {
	// contains filtered or unexported fields
}

BoolBuilder builds a boolean field represented by T.

func Bool

func Bool(name string) *BoolBuilder[bool]

Bool returns a boolean field.

func BoolAs added in v0.2.0

func BoolAs[T any](name string) *BoolBuilder[T]

BoolAs returns a boolean field represented by T.

func (BoolBuilder) Codec added in v0.2.0

func (b BoolBuilder) Codec(codec TypeValueScanner[T]) B

Codec attaches an external value scanner for the represented Go value.

type BytesBuilder added in v0.2.0

type BytesBuilder[T any] struct {
	// contains filtered or unexported fields
}

BytesBuilder builds a bytes field represented by T.

func Bytes

func Bytes(name string) *BytesBuilder[[]byte]

Bytes returns a byte-slice field.

func BytesAs added in v0.2.0

func BytesAs[T any](name string) *BytesBuilder[T]

BytesAs returns a bytes field represented by T.

func (BytesBuilder) Codec added in v0.2.0

func (b BytesBuilder) Codec(codec TypeValueScanner[T]) B

Codec attaches an external value scanner for the represented Go value.

func (*BytesBuilder[T]) MaxLen added in v0.2.0

func (b *BytesBuilder[T]) MaxLen(length int) *BytesBuilder[T]

MaxLen adds a base byte-slice length validator.

func (*BytesBuilder[T]) MinLen added in v0.2.0

func (b *BytesBuilder[T]) MinLen(length int) *BytesBuilder[T]

MinLen adds a base byte-slice length validator.

func (*BytesBuilder[T]) NotEmpty added in v0.2.0

func (b *BytesBuilder[T]) NotEmpty() *BytesBuilder[T]

NotEmpty rejects empty base byte slices.

func (*BytesBuilder[T]) Sensitive added in v0.2.0

func (b *BytesBuilder[T]) Sensitive() *BytesBuilder[T]

Sensitive prevents the field from being printed or serialized.

func (*BytesBuilder[T]) Unique added in v0.2.0

func (b *BytesBuilder[T]) Unique() *BytesBuilder[T]

Unique makes the field unique.

type Descriptor

type Descriptor struct {
	Tag              string                  // struct tag.
	Size             int                     // varchar size.
	Name             string                  // field name.
	Type             Type                    // logical field type.
	RuntimeType      reflect.Type            `json:"-"` // opaque key for compiler-authored type metadata.
	ValueScanner     any                     // custom field codec.
	Unique           bool                    // unique index of field.
	Nillable         bool                    // nillable struct field.
	Optional         bool                    // nullable field in database.
	Immutable        bool                    // create only field.
	Default          any                     // default value on create.
	UpdateDefault    any                     // default value on update.
	Validators       []any                   // validator functions in fluent call order.
	ValidatorKinds   []ValidatorKind         // accepted value kind for each validator.
	StorageKey       string                  // sql column name.
	Enums            []struct{ N, V string } // enum values.
	Sensitive        bool                    // sensitive info string field.
	SchemaType       map[string]string       // override the schema type.
	Annotations      []schema.Annotation     // field annotations.
	Comment          string                  // field comment.
	Deprecated       bool                    // mark the field as deprecated.
	DeprecatedReason string                  // deprecation reason.
	Err              error
}

A Descriptor describes a field configuration.

type EnumBuilder added in v0.2.0

type EnumBuilder[T any] struct {
	// contains filtered or unexported fields
}

EnumBuilder builds an enum field represented by T.

func Enum

func Enum(name string) *EnumBuilder[string]

Enum returns a string-backed enum field.

func EnumAs added in v0.2.0

func EnumAs[T any](name string) *EnumBuilder[T]

EnumAs returns an enum field represented by T.

func (EnumBuilder) Codec added in v0.2.0

func (b EnumBuilder) Codec(codec TypeValueScanner[T]) B

Codec attaches an external value scanner for the represented Go value.

func (*EnumBuilder[T]) NamedValues added in v0.2.0

func (b *EnumBuilder[T]) NamedValues(nameValues ...string) *EnumBuilder[T]

NamedValues adds alternating Go name and database value pairs.

func (*EnumBuilder[T]) Values added in v0.2.0

func (b *EnumBuilder[T]) Values(values ...string) *EnumBuilder[T]

Values adds enum values whose Go names and database values are equal.

func (*EnumBuilder[T]) ValuesFrom added in v0.2.0

func (b *EnumBuilder[T]) ValuesFrom(values EnumValues) *EnumBuilder[T]

ValuesFrom adds enum values supplied by T.

type EnumValues

type EnumValues interface {
	Values() []string
}

EnumValues supplies the values of an enum representation.

type Float32Builder added in v0.2.0

type Float32Builder[T any] struct {
	// contains filtered or unexported fields
}

Float32Builder builds a float32 field represented by T.

func Float32

func Float32(name string) *Float32Builder[float32]

Float32 returns a float32 field.

func Float32As added in v0.2.0

func Float32As[T any](name string) *Float32Builder[T]

Float32As returns a float32 field represented by T.

func (Float32Builder) Max added in v0.2.0

func (b Float32Builder) Max(maximum N) B

Max adds a base numeric maximum validator.

func (Float32Builder) Min added in v0.2.0

func (b Float32Builder) Min(minimum N) B

Min adds a base numeric minimum validator.

func (*Float32Builder[T]) Negative added in v0.2.0

func (b *Float32Builder[T]) Negative() *Float32Builder[T]

Negative adds a base float32 maximum validator.

func (*Float32Builder[T]) Positive added in v0.2.0

func (b *Float32Builder[T]) Positive() *Float32Builder[T]

Positive adds a base float32 minimum validator.

func (Float32Builder) Range added in v0.2.0

func (b Float32Builder) Range(minimum, maximum N) B

Range adds a base numeric inclusive-range validator.

func (Float32Builder) Unique added in v0.2.0

func (b Float32Builder) Unique() B

Unique makes the field unique.

type Float64Builder added in v0.2.0

type Float64Builder[T any] struct {
	// contains filtered or unexported fields
}

Float64Builder builds a float64 field represented by T.

func Float

func Float(name string) *Float64Builder[float64]

Float returns a float64 field.

func Float64As added in v0.2.0

func Float64As[T any](name string) *Float64Builder[T]

Float64As returns a float64 field represented by T.

func FloatAs added in v0.2.0

func FloatAs[T any](name string) *Float64Builder[T]

FloatAs returns a float64 field represented by T.

func (Float64Builder) Max added in v0.2.0

func (b Float64Builder) Max(maximum N) B

Max adds a base numeric maximum validator.

func (Float64Builder) Min added in v0.2.0

func (b Float64Builder) Min(minimum N) B

Min adds a base numeric minimum validator.

func (*Float64Builder[T]) Negative added in v0.2.0

func (b *Float64Builder[T]) Negative() *Float64Builder[T]

Negative adds a base float64 maximum validator.

func (*Float64Builder[T]) Positive added in v0.2.0

func (b *Float64Builder[T]) Positive() *Float64Builder[T]

Positive adds a base float64 minimum validator.

func (Float64Builder) Range added in v0.2.0

func (b Float64Builder) Range(minimum, maximum N) B

Range adds a base numeric inclusive-range validator.

func (Float64Builder) Unique added in v0.2.0

func (b Float64Builder) Unique() B

Unique makes the field unique.

type Int8Builder added in v0.2.0

type Int8Builder[T any] struct {
	// contains filtered or unexported fields
}

Int8Builder builds an int8 field represented by T.

func Int8

func Int8(name string) *Int8Builder[int8]

Int8 returns an int8 field.

func Int8As added in v0.2.0

func Int8As[T any](name string) *Int8Builder[T]

Int8As returns an int8 field represented by T.

func (Int8Builder) Max added in v0.2.0

func (b Int8Builder) Max(maximum N) B

Max adds a base numeric maximum validator.

func (Int8Builder) Min added in v0.2.0

func (b Int8Builder) Min(minimum N) B

Min adds a base numeric minimum validator.

func (*Int8Builder[T]) Negative added in v0.2.0

func (b *Int8Builder[T]) Negative() *Int8Builder[T]

Negative adds a base int8 maximum validator.

func (*Int8Builder[T]) NonNegative added in v0.2.0

func (b *Int8Builder[T]) NonNegative() *Int8Builder[T]

NonNegative adds a base int8 minimum validator.

func (*Int8Builder[T]) Positive added in v0.2.0

func (b *Int8Builder[T]) Positive() *Int8Builder[T]

Positive adds a base int8 minimum validator.

func (Int8Builder) Range added in v0.2.0

func (b Int8Builder) Range(minimum, maximum N) B

Range adds a base numeric inclusive-range validator.

func (Int8Builder) Unique added in v0.2.0

func (b Int8Builder) Unique() B

Unique makes the field unique.

type Int16Builder added in v0.2.0

type Int16Builder[T any] struct {
	// contains filtered or unexported fields
}

Int16Builder builds an int16 field represented by T.

func Int16

func Int16(name string) *Int16Builder[int16]

Int16 returns an int16 field.

func Int16As added in v0.2.0

func Int16As[T any](name string) *Int16Builder[T]

Int16As returns an int16 field represented by T.

func (Int16Builder) Max added in v0.2.0

func (b Int16Builder) Max(maximum N) B

Max adds a base numeric maximum validator.

func (Int16Builder) Min added in v0.2.0

func (b Int16Builder) Min(minimum N) B

Min adds a base numeric minimum validator.

func (*Int16Builder[T]) Negative added in v0.2.0

func (b *Int16Builder[T]) Negative() *Int16Builder[T]

Negative adds a base int16 maximum validator.

func (*Int16Builder[T]) NonNegative added in v0.2.0

func (b *Int16Builder[T]) NonNegative() *Int16Builder[T]

NonNegative adds a base int16 minimum validator.

func (*Int16Builder[T]) Positive added in v0.2.0

func (b *Int16Builder[T]) Positive() *Int16Builder[T]

Positive adds a base int16 minimum validator.

func (Int16Builder) Range added in v0.2.0

func (b Int16Builder) Range(minimum, maximum N) B

Range adds a base numeric inclusive-range validator.

func (Int16Builder) Unique added in v0.2.0

func (b Int16Builder) Unique() B

Unique makes the field unique.

type Int32Builder added in v0.2.0

type Int32Builder[T any] struct {
	// contains filtered or unexported fields
}

Int32Builder builds an int32 field represented by T.

func Int32

func Int32(name string) *Int32Builder[int32]

Int32 returns an int32 field.

func Int32As added in v0.2.0

func Int32As[T any](name string) *Int32Builder[T]

Int32As returns an int32 field represented by T.

func (Int32Builder) Max added in v0.2.0

func (b Int32Builder) Max(maximum N) B

Max adds a base numeric maximum validator.

func (Int32Builder) Min added in v0.2.0

func (b Int32Builder) Min(minimum N) B

Min adds a base numeric minimum validator.

func (*Int32Builder[T]) Negative added in v0.2.0

func (b *Int32Builder[T]) Negative() *Int32Builder[T]

Negative adds a base int32 maximum validator.

func (*Int32Builder[T]) NonNegative added in v0.2.0

func (b *Int32Builder[T]) NonNegative() *Int32Builder[T]

NonNegative adds a base int32 minimum validator.

func (*Int32Builder[T]) Positive added in v0.2.0

func (b *Int32Builder[T]) Positive() *Int32Builder[T]

Positive adds a base int32 minimum validator.

func (Int32Builder) Range added in v0.2.0

func (b Int32Builder) Range(minimum, maximum N) B

Range adds a base numeric inclusive-range validator.

func (Int32Builder) Unique added in v0.2.0

func (b Int32Builder) Unique() B

Unique makes the field unique.

type Int64Builder added in v0.2.0

type Int64Builder[T any] struct {
	// contains filtered or unexported fields
}

Int64Builder builds an int64 field represented by T.

func Int64

func Int64(name string) *Int64Builder[int64]

Int64 returns an int64 field.

func Int64As added in v0.2.0

func Int64As[T any](name string) *Int64Builder[T]

Int64As returns an int64 field represented by T.

func (Int64Builder) Max added in v0.2.0

func (b Int64Builder) Max(maximum N) B

Max adds a base numeric maximum validator.

func (Int64Builder) Min added in v0.2.0

func (b Int64Builder) Min(minimum N) B

Min adds a base numeric minimum validator.

func (*Int64Builder[T]) Negative added in v0.2.0

func (b *Int64Builder[T]) Negative() *Int64Builder[T]

Negative adds a base int64 maximum validator.

func (*Int64Builder[T]) NonNegative added in v0.2.0

func (b *Int64Builder[T]) NonNegative() *Int64Builder[T]

NonNegative adds a base int64 minimum validator.

func (*Int64Builder[T]) Positive added in v0.2.0

func (b *Int64Builder[T]) Positive() *Int64Builder[T]

Positive adds a base int64 minimum validator.

func (Int64Builder) Range added in v0.2.0

func (b Int64Builder) Range(minimum, maximum N) B

Range adds a base numeric inclusive-range validator.

func (Int64Builder) Unique added in v0.2.0

func (b Int64Builder) Unique() B

Unique makes the field unique.

type IntBuilder added in v0.2.0

type IntBuilder[T any] struct {
	// contains filtered or unexported fields
}

IntBuilder builds an int field represented by T.

func Int

func Int(name string) *IntBuilder[int]

Int returns an int field.

func IntAs added in v0.2.0

func IntAs[T any](name string) *IntBuilder[T]

IntAs returns an int field represented by T.

func (IntBuilder) Max added in v0.2.0

func (b IntBuilder) Max(maximum N) B

Max adds a base numeric maximum validator.

func (IntBuilder) Min added in v0.2.0

func (b IntBuilder) Min(minimum N) B

Min adds a base numeric minimum validator.

func (*IntBuilder[T]) Negative added in v0.2.0

func (b *IntBuilder[T]) Negative() *IntBuilder[T]

Negative adds a base int maximum validator.

func (*IntBuilder[T]) NonNegative added in v0.2.0

func (b *IntBuilder[T]) NonNegative() *IntBuilder[T]

NonNegative adds a base int minimum validator.

func (*IntBuilder[T]) Positive added in v0.2.0

func (b *IntBuilder[T]) Positive() *IntBuilder[T]

Positive adds a base int minimum validator.

func (IntBuilder) Range added in v0.2.0

func (b IntBuilder) Range(minimum, maximum N) B

Range adds a base numeric inclusive-range validator.

func (IntBuilder) Unique added in v0.2.0

func (b IntBuilder) Unique() B

Unique makes the field unique.

type JSONBuilder added in v0.2.0

type JSONBuilder[T any] struct {
	// contains filtered or unexported fields
}

JSONBuilder builds a JSON field represented by T.

func Any

func Any(name string) *JSONBuilder[any]

Any returns a JSON field represented by any.

func Floats

func Floats(name string) *JSONBuilder[[]float64]

Floats returns a JSON field represented by []float64.

func Ints

func Ints(name string) *JSONBuilder[[]int]

Ints returns a JSON field represented by []int.

func JSON

func JSON[T any](name string) *JSONBuilder[T]

JSON returns a JSON field represented by T.

func Strings

func Strings(name string) *JSONBuilder[[]string]

Strings returns a JSON field represented by []string.

func (JSONBuilder) Annotations added in v0.2.0

func (b JSONBuilder) Annotations(annotations ...schema.Annotation) B

Annotations adds code-generation annotations.

func (JSONBuilder) Comment added in v0.2.0

func (b JSONBuilder) Comment(comment string) B

Comment sets the field comment.

func (JSONBuilder) Default added in v0.2.0

func (b JSONBuilder) Default(value T) B

Default sets the default value used on creation.

func (JSONBuilder) DefaultFunc added in v0.2.0

func (b JSONBuilder) DefaultFunc(fn func() T) B

DefaultFunc sets the function used to generate a default value on creation.

func (JSONBuilder) Deprecated added in v0.2.0

func (b JSONBuilder) Deprecated(reason ...string) B

Deprecated marks the field as deprecated.

func (JSONBuilder) Descriptor added in v0.2.0

func (b JSONBuilder) Descriptor() *Descriptor

Descriptor implements ent.Field.

func (JSONBuilder) Immutable added in v0.2.0

func (b JSONBuilder) Immutable() B

Immutable prevents the field from being updated.

func (JSONBuilder) Nillable added in v0.2.0

func (b JSONBuilder) Nillable() B

Nillable makes the generated struct field a pointer.

func (JSONBuilder) Optional added in v0.2.0

func (b JSONBuilder) Optional() B

Optional makes the field optional on creation.

func (JSONBuilder) SchemaType added in v0.2.0

func (b JSONBuilder) SchemaType(types map[string]string) B

SchemaType overrides the database type by dialect.

func (*JSONBuilder[T]) Sensitive added in v0.2.0

func (b *JSONBuilder[T]) Sensitive() *JSONBuilder[T]

Sensitive prevents the field from being printed or serialized.

func (JSONBuilder) StorageKey added in v0.2.0

func (b JSONBuilder) StorageKey(key string) B

StorageKey sets the storage column name.

func (JSONBuilder) StructTag added in v0.2.0

func (b JSONBuilder) StructTag(tag string) B

StructTag sets the struct tag.

func (JSONBuilder) UpdateDefault added in v0.2.0

func (b JSONBuilder) UpdateDefault(fn func() T) B

UpdateDefault sets the function used to generate a default value on update.

func (JSONBuilder) Validate added in v0.2.0

func (b JSONBuilder) Validate(fn func(T) error) B

Validate adds a validator for the represented Go value.

type OtherBuilder added in v0.2.0

type OtherBuilder[T any] struct {
	// contains filtered or unexported fields
}

OtherBuilder builds an otherwise unsupported field represented by T.

func Other

func Other[T any](name string) *OtherBuilder[T]

Other returns an otherwise unsupported field represented by T.

func (OtherBuilder) Codec added in v0.2.0

func (b OtherBuilder) Codec(codec TypeValueScanner[T]) B

Codec attaches an external value scanner for the represented Go value.

func (*OtherBuilder[T]) Descriptor added in v0.2.0

func (b *OtherBuilder[T]) Descriptor() *Descriptor

Descriptor implements ent.Field and checks Other's storage requirement.

func (*OtherBuilder[T]) Sensitive added in v0.2.0

func (b *OtherBuilder[T]) Sensitive() *OtherBuilder[T]

Sensitive prevents the field from being printed or serialized.

func (*OtherBuilder[T]) Unique added in v0.2.0

func (b *OtherBuilder[T]) Unique() *OtherBuilder[T]

Unique makes the field unique.

type StringBuilder added in v0.2.0

type StringBuilder[T any] struct {
	// contains filtered or unexported fields
}

StringBuilder builds a string-family field represented by T.

func String

func String(name string) *StringBuilder[string]

String returns a string field.

func StringAs added in v0.2.0

func StringAs[T any](name string) *StringBuilder[T]

StringAs returns a string field represented by T.

func Text

func Text(name string) *StringBuilder[string]

Text returns an unlimited-size string field.

func TextAs added in v0.2.0

func TextAs[T any](name string) *StringBuilder[T]

TextAs returns an unlimited-size string field represented by T.

func (StringBuilder) Codec added in v0.2.0

func (b StringBuilder) Codec(codec TypeValueScanner[T]) B

Codec attaches an external value scanner for the represented Go value.

func (*StringBuilder[T]) Match added in v0.2.0

func (b *StringBuilder[T]) Match(expression *regexp.Regexp) *StringBuilder[T]

Match adds a base string regular-expression validator.

func (*StringBuilder[T]) MaxLen added in v0.2.0

func (b *StringBuilder[T]) MaxLen(length int) *StringBuilder[T]

MaxLen adds a base string byte-length validator.

func (*StringBuilder[T]) MaxRuneLen added in v0.2.0

func (b *StringBuilder[T]) MaxRuneLen(length int) *StringBuilder[T]

MaxRuneLen adds a base string rune-length validator.

func (*StringBuilder[T]) MinLen added in v0.2.0

func (b *StringBuilder[T]) MinLen(length int) *StringBuilder[T]

MinLen adds a base string byte-length validator.

func (*StringBuilder[T]) MinRuneLen added in v0.2.0

func (b *StringBuilder[T]) MinRuneLen(length int) *StringBuilder[T]

MinRuneLen adds a base string rune-length validator.

func (*StringBuilder[T]) NotEmpty added in v0.2.0

func (b *StringBuilder[T]) NotEmpty() *StringBuilder[T]

NotEmpty rejects empty base strings.

func (*StringBuilder[T]) Sensitive added in v0.2.0

func (b *StringBuilder[T]) Sensitive() *StringBuilder[T]

Sensitive prevents the field from being printed or serialized.

func (*StringBuilder[T]) Unique added in v0.2.0

func (b *StringBuilder[T]) Unique() *StringBuilder[T]

Unique makes the field unique.

type TextValueScanner

type TextValueScanner[T interface {
	encoding.TextMarshaler
	encoding.TextUnmarshaler
}] struct{}

TextValueScanner stores values with encoding.TextMarshaler and scans them with encoding.TextUnmarshaler.

func (TextValueScanner[T]) FromValue

func (TextValueScanner[T]) FromValue(value driver.Value) (ret T, err error)

FromValue implements TypeValueScanner.FromValue.

func (TextValueScanner[T]) ScanValue

func (TextValueScanner[T]) ScanValue() ValueScanner

ScanValue implements TypeValueScanner.ScanValue.

func (TextValueScanner[T]) Value

func (TextValueScanner[T]) Value(value T) (driver.Value, error)

Value implements TypeValueScanner.Value.

type TimeBuilder added in v0.2.0

type TimeBuilder[T any] struct {
	// contains filtered or unexported fields
}

TimeBuilder builds a time field represented by T.

func Time

func Time(name string) *TimeBuilder[time.Time]

Time returns a time.Time field.

func TimeAs added in v0.2.0

func TimeAs[T any](name string) *TimeBuilder[T]

TimeAs returns a time field represented by T.

func (TimeBuilder) Codec added in v0.2.0

func (b TimeBuilder) Codec(codec TypeValueScanner[T]) B

Codec attaches an external value scanner for the represented Go value.

func (*TimeBuilder[T]) Unique added in v0.2.0

func (b *TimeBuilder[T]) Unique() *TimeBuilder[T]

Unique makes the field unique.

type Type

type Type uint8

A Type represents a logical field type.

const (
	TypeInvalid Type = iota
	TypeBool
	TypeTime
	TypeJSON
	TypeUUID
	TypeBytes
	TypeEnum
	TypeString
	TypeOther
	TypeInt8
	TypeInt16
	TypeInt32
	TypeInt
	TypeInt64
	TypeUint8
	TypeUint16
	TypeUint32
	TypeUint
	TypeUint64
	TypeFloat32
	TypeFloat64
)

List of field types.

func (Type) ConstName

func (t Type) ConstName() string

ConstName returns the Go constant name of t.

func (Type) Float

func (t Type) Float() bool

Float reports whether t is floating point.

func (Type) Integer

func (t Type) Integer() bool

Integer reports whether t is integral.

func (Type) Numeric

func (t Type) Numeric() bool

Numeric reports whether t is numeric.

func (Type) String

func (t Type) String() string

String returns the string representation of a type.

func (Type) Valid

func (t Type) Valid() bool

Valid reports whether t is a known field type.

type TypeValueScanner

type TypeValueScanner[T any] interface {
	Value(T) (driver.Value, error)
	ScanValue() ValueScanner
	FromValue(driver.Value) (T, error)
}

TypeValueScanner converts between a represented Go value and its database scanner.

type UUIDBuilder added in v0.2.0

type UUIDBuilder[T any] struct {
	// contains filtered or unexported fields
}

UUIDBuilder builds a UUID field represented by T.

func UUID

func UUID[T any](name string) *UUIDBuilder[T]

UUID returns a UUID field represented by T.

func (UUIDBuilder) Codec added in v0.2.0

func (b UUIDBuilder) Codec(codec TypeValueScanner[T]) B

Codec attaches an external value scanner for the represented Go value.

func (*UUIDBuilder[T]) Unique added in v0.2.0

func (b *UUIDBuilder[T]) Unique() *UUIDBuilder[T]

Unique makes the field unique.

type Uint8Builder added in v0.2.0

type Uint8Builder[T any] struct {
	// contains filtered or unexported fields
}

Uint8Builder builds a uint8 field represented by T.

func Uint8

func Uint8(name string) *Uint8Builder[uint8]

Uint8 returns a uint8 field.

func Uint8As added in v0.2.0

func Uint8As[T any](name string) *Uint8Builder[T]

Uint8As returns a uint8 field represented by T.

func (Uint8Builder) Max added in v0.2.0

func (b Uint8Builder) Max(maximum N) B

Max adds a base numeric maximum validator.

func (Uint8Builder) Min added in v0.2.0

func (b Uint8Builder) Min(minimum N) B

Min adds a base numeric minimum validator.

func (*Uint8Builder[T]) Positive added in v0.2.0

func (b *Uint8Builder[T]) Positive() *Uint8Builder[T]

Positive adds a base uint8 minimum validator.

func (Uint8Builder) Range added in v0.2.0

func (b Uint8Builder) Range(minimum, maximum N) B

Range adds a base numeric inclusive-range validator.

func (Uint8Builder) Unique added in v0.2.0

func (b Uint8Builder) Unique() B

Unique makes the field unique.

type Uint16Builder added in v0.2.0

type Uint16Builder[T any] struct {
	// contains filtered or unexported fields
}

Uint16Builder builds a uint16 field represented by T.

func Uint16

func Uint16(name string) *Uint16Builder[uint16]

Uint16 returns a uint16 field.

func Uint16As added in v0.2.0

func Uint16As[T any](name string) *Uint16Builder[T]

Uint16As returns a uint16 field represented by T.

func (Uint16Builder) Max added in v0.2.0

func (b Uint16Builder) Max(maximum N) B

Max adds a base numeric maximum validator.

func (Uint16Builder) Min added in v0.2.0

func (b Uint16Builder) Min(minimum N) B

Min adds a base numeric minimum validator.

func (*Uint16Builder[T]) Positive added in v0.2.0

func (b *Uint16Builder[T]) Positive() *Uint16Builder[T]

Positive adds a base uint16 minimum validator.

func (Uint16Builder) Range added in v0.2.0

func (b Uint16Builder) Range(minimum, maximum N) B

Range adds a base numeric inclusive-range validator.

func (Uint16Builder) Unique added in v0.2.0

func (b Uint16Builder) Unique() B

Unique makes the field unique.

type Uint32Builder added in v0.2.0

type Uint32Builder[T any] struct {
	// contains filtered or unexported fields
}

Uint32Builder builds a uint32 field represented by T.

func Uint32

func Uint32(name string) *Uint32Builder[uint32]

Uint32 returns a uint32 field.

func Uint32As added in v0.2.0

func Uint32As[T any](name string) *Uint32Builder[T]

Uint32As returns a uint32 field represented by T.

func (Uint32Builder) Max added in v0.2.0

func (b Uint32Builder) Max(maximum N) B

Max adds a base numeric maximum validator.

func (Uint32Builder) Min added in v0.2.0

func (b Uint32Builder) Min(minimum N) B

Min adds a base numeric minimum validator.

func (*Uint32Builder[T]) Positive added in v0.2.0

func (b *Uint32Builder[T]) Positive() *Uint32Builder[T]

Positive adds a base uint32 minimum validator.

func (Uint32Builder) Range added in v0.2.0

func (b Uint32Builder) Range(minimum, maximum N) B

Range adds a base numeric inclusive-range validator.

func (Uint32Builder) Unique added in v0.2.0

func (b Uint32Builder) Unique() B

Unique makes the field unique.

type Uint64Builder added in v0.2.0

type Uint64Builder[T any] struct {
	// contains filtered or unexported fields
}

Uint64Builder builds a uint64 field represented by T.

func Uint64

func Uint64(name string) *Uint64Builder[uint64]

Uint64 returns a uint64 field.

func Uint64As added in v0.2.0

func Uint64As[T any](name string) *Uint64Builder[T]

Uint64As returns a uint64 field represented by T.

func (Uint64Builder) Max added in v0.2.0

func (b Uint64Builder) Max(maximum N) B

Max adds a base numeric maximum validator.

func (Uint64Builder) Min added in v0.2.0

func (b Uint64Builder) Min(minimum N) B

Min adds a base numeric minimum validator.

func (*Uint64Builder[T]) Positive added in v0.2.0

func (b *Uint64Builder[T]) Positive() *Uint64Builder[T]

Positive adds a base uint64 minimum validator.

func (Uint64Builder) Range added in v0.2.0

func (b Uint64Builder) Range(minimum, maximum N) B

Range adds a base numeric inclusive-range validator.

func (Uint64Builder) Unique added in v0.2.0

func (b Uint64Builder) Unique() B

Unique makes the field unique.

type UintBuilder added in v0.2.0

type UintBuilder[T any] struct {
	// contains filtered or unexported fields
}

UintBuilder builds a uint field represented by T.

func Uint

func Uint(name string) *UintBuilder[uint]

Uint returns a uint field.

func UintAs added in v0.2.0

func UintAs[T any](name string) *UintBuilder[T]

UintAs returns a uint field represented by T.

func (UintBuilder) Max added in v0.2.0

func (b UintBuilder) Max(maximum N) B

Max adds a base numeric maximum validator.

func (UintBuilder) Min added in v0.2.0

func (b UintBuilder) Min(minimum N) B

Min adds a base numeric minimum validator.

func (*UintBuilder[T]) Positive added in v0.2.0

func (b *UintBuilder[T]) Positive() *UintBuilder[T]

Positive adds a base uint minimum validator.

func (UintBuilder) Range added in v0.2.0

func (b UintBuilder) Range(minimum, maximum N) B

Range adds a base numeric inclusive-range validator.

func (UintBuilder) Unique added in v0.2.0

func (b UintBuilder) Unique() B

Unique makes the field unique.

type Validator

type Validator interface {
	Validate() error
}

Validator wraps the Validate method recognized on represented field types.

type ValidatorKind added in v0.2.0

type ValidatorKind uint8

ValidatorKind identifies the value accepted by a field validator.

const (
	// ValidatorLogical accepts the field family's logical base value.
	ValidatorLogical ValidatorKind = iota
	// ValidatorRepresentation accepts the generated Go representation.
	ValidatorRepresentation
)

type ValueScanner

type ValueScanner interface {
	driver.Valuer
	sql.Scanner
}

ValueScanner groups the database value and scan methods implemented by custom Go types.

type ValueScannerFunc

type ValueScannerFunc[T any, S ValueScanner] struct {
	V func(T) (driver.Value, error)
	S func(S) (T, error)
}

ValueScannerFunc adapts conversion functions to TypeValueScanner.

func (ValueScannerFunc[T, S]) FromValue

func (f ValueScannerFunc[T, S]) FromValue(value driver.Value) (T, error)

FromValue implements TypeValueScanner.FromValue.

func (ValueScannerFunc[T, S]) ScanValue

func (f ValueScannerFunc[T, S]) ScanValue() ValueScanner

ScanValue implements TypeValueScanner.ScanValue.

func (ValueScannerFunc[T, S]) Value

func (f ValueScannerFunc[T, S]) Value(value T) (driver.Value, error)

Value implements TypeValueScanner.Value.

Directories

Path Synopsis
gen is a codegen cmd for generating numeric build types from template.
gen is a codegen cmd for generating numeric build types from template.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL