Documentation
¶
Index ¶
- type Annotation
- type BinaryValueScanner
- type BoolBuilder
- type BytesBuilder
- func (b BytesBuilder) Codec(codec TypeValueScanner[T]) B
- func (b *BytesBuilder[T]) MaxLen(length int) *BytesBuilder[T]
- func (b *BytesBuilder[T]) MinLen(length int) *BytesBuilder[T]
- func (b *BytesBuilder[T]) NotEmpty() *BytesBuilder[T]
- func (b *BytesBuilder[T]) Sensitive() *BytesBuilder[T]
- func (b *BytesBuilder[T]) Unique() *BytesBuilder[T]
- type Descriptor
- type EnumBuilder
- type EnumValues
- type Float32Builder
- type Float64Builder
- type Int8Builder
- func (b Int8Builder) Max(maximum N) B
- func (b Int8Builder) Min(minimum N) B
- func (b *Int8Builder[T]) Negative() *Int8Builder[T]
- func (b *Int8Builder[T]) NonNegative() *Int8Builder[T]
- func (b *Int8Builder[T]) Positive() *Int8Builder[T]
- func (b Int8Builder) Range(minimum, maximum N) B
- func (b Int8Builder) Unique() B
- type Int16Builder
- func (b Int16Builder) Max(maximum N) B
- func (b Int16Builder) Min(minimum N) B
- func (b *Int16Builder[T]) Negative() *Int16Builder[T]
- func (b *Int16Builder[T]) NonNegative() *Int16Builder[T]
- func (b *Int16Builder[T]) Positive() *Int16Builder[T]
- func (b Int16Builder) Range(minimum, maximum N) B
- func (b Int16Builder) Unique() B
- type Int32Builder
- func (b Int32Builder) Max(maximum N) B
- func (b Int32Builder) Min(minimum N) B
- func (b *Int32Builder[T]) Negative() *Int32Builder[T]
- func (b *Int32Builder[T]) NonNegative() *Int32Builder[T]
- func (b *Int32Builder[T]) Positive() *Int32Builder[T]
- func (b Int32Builder) Range(minimum, maximum N) B
- func (b Int32Builder) Unique() B
- type Int64Builder
- func (b Int64Builder) Max(maximum N) B
- func (b Int64Builder) Min(minimum N) B
- func (b *Int64Builder[T]) Negative() *Int64Builder[T]
- func (b *Int64Builder[T]) NonNegative() *Int64Builder[T]
- func (b *Int64Builder[T]) Positive() *Int64Builder[T]
- func (b Int64Builder) Range(minimum, maximum N) B
- func (b Int64Builder) Unique() B
- type IntBuilder
- func (b IntBuilder) Max(maximum N) B
- func (b IntBuilder) Min(minimum N) B
- func (b *IntBuilder[T]) Negative() *IntBuilder[T]
- func (b *IntBuilder[T]) NonNegative() *IntBuilder[T]
- func (b *IntBuilder[T]) Positive() *IntBuilder[T]
- func (b IntBuilder) Range(minimum, maximum N) B
- func (b IntBuilder) Unique() B
- type JSONBuilder
- func (b JSONBuilder) Annotations(annotations ...schema.Annotation) B
- func (b JSONBuilder) Comment(comment string) B
- func (b JSONBuilder) Default(value T) B
- func (b JSONBuilder) DefaultFunc(fn func() T) B
- func (b JSONBuilder) Deprecated(reason ...string) B
- func (b JSONBuilder) Descriptor() *Descriptor
- func (b JSONBuilder) Immutable() B
- func (b JSONBuilder) Nillable() B
- func (b JSONBuilder) Optional() B
- func (b JSONBuilder) SchemaType(types map[string]string) B
- func (b *JSONBuilder[T]) Sensitive() *JSONBuilder[T]
- func (b JSONBuilder) StorageKey(key string) B
- func (b JSONBuilder) StructTag(tag string) B
- func (b JSONBuilder) UpdateDefault(fn func() T) B
- func (b JSONBuilder) Validate(fn func(T) error) B
- type OtherBuilder
- type StringBuilder
- func (b StringBuilder) Codec(codec TypeValueScanner[T]) B
- func (b *StringBuilder[T]) Match(expression *regexp.Regexp) *StringBuilder[T]
- func (b *StringBuilder[T]) MaxLen(length int) *StringBuilder[T]
- func (b *StringBuilder[T]) MaxRuneLen(length int) *StringBuilder[T]
- func (b *StringBuilder[T]) MinLen(length int) *StringBuilder[T]
- func (b *StringBuilder[T]) MinRuneLen(length int) *StringBuilder[T]
- func (b *StringBuilder[T]) NotEmpty() *StringBuilder[T]
- func (b *StringBuilder[T]) Sensitive() *StringBuilder[T]
- func (b *StringBuilder[T]) Unique() *StringBuilder[T]
- type TextValueScanner
- type TimeBuilder
- type Type
- type TypeValueScanner
- type UUIDBuilder
- type Uint8Builder
- type Uint16Builder
- type Uint32Builder
- type Uint64Builder
- type UintBuilder
- type Validator
- type ValidatorKind
- type ValueScanner
- type ValueScannerFunc
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.
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.
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 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 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 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 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.
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 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.
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 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.
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 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.
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 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.
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 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.
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 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.
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 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
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.
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 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.
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 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.
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 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.
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 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.
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 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.
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 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.
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 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.
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 ¶
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.