Documentation
¶
Index ¶
- Constants
- type CandidatePolicy
- type Check
- type CheckKid
- type Checks
- type Option
- func WithCandidatePolicies(policies []CandidatePolicy) Option
- func WithFieldFilter(include func(field string) bool) Option
- func WithLocation(location string) Option
- func WithMaxPlaceholders(size int) Option
- func WithPrevious(previous interface{}) Option
- func WithRef(flag bool) Option
- func WithSetMarker() Option
- func WithShallow(flag bool) Option
- func WithTransaction(tx *sql.Tx) Option
- func WithUnique(flag bool) Option
- type Options
- type Path
- type Reference
- type Service
- type Validation
- func (e *Validation) AppendNotNull(path *Path, field, msg string)
- func (e *Validation) AppendRef(path *Path, field string, value interface{}, msg string)
- func (e *Validation) AppendUnique(path *Path, field string, value interface{}, msg string)
- func (e *Validation) Error() string
- func (e *Validation) String() string
- type Violation
Constants ¶
const ( CheckKidUnique = CheckKid("unique") CheckKidRefKey = CheckKid("refKey") CheckKidNotNull = CheckKid("notnull") )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CandidatePolicy ¶ added in v0.26.0
type CandidatePolicy struct {
Previous any
FieldFilter func(string) bool
// DeferredFields marks temporarily unavailable INSERT inputs, independently
// of sparse coverage. A nonnil function requires nil normalized Previous.
DeferredFields func(string) bool
// SatisfiedReferences are trusted, exact reference receipts for this insert.
// They require nil normalized Previous and nil DeferredFields.
SatisfiedReferences []Reference
}
type Checks ¶ added in v0.5.1
type Checks struct {
Type reflect.Type
Unique []*Check
RefKey []*Check
NoNull []*Check
// contains filtered or unexported fields
}
func (*Checks) ValidateReferences ¶ added in v0.26.0
ValidateReferences rejects unknown, wrong-target and duplicate receipts using compiled metadata. It performs no validation callbacks or database queries.
type Option ¶
type Option func(c *Options)
func WithCandidatePolicies ¶ added in v0.26.0
func WithCandidatePolicies(policies []CandidatePolicy) Option
WithCandidatePolicies supplies an aligned policy for each root candidate in a shallow batch. Nil Previous means insert; nil FieldFilter means full coverage. A typed nil Previous must point to the candidate's struct type. Empty typed batches must contain structs or struct pointers; empty []any is also accepted.
func WithFieldFilter ¶ added in v0.26.0
WithFieldFilter supplies explicit validation coverage in canonical Go field names. A nonnil filter takes precedence over WithSetMarker; it does not modify any marker. Nil leaves the default full/marker-gated behavior unchanged.
func WithLocation ¶ added in v0.5.2
WithLocation creates with location option
func WithMaxPlaceholders ¶ added in v0.24.0
WithMaxPlaceholders sets the maximum placeholder count for validator queries.
func WithPrevious ¶ added in v0.26.0
func WithPrevious(previous interface{}) Option
WithPrevious selects exact per-candidate uniqueness checks. Each previous row must already be identity-matched to the corresponding candidate by the caller. Nil means every candidate is an insert and excludes no stored row. A supplied collection must have exactly one entry per candidate; nil entries are inserts. Previous rows must have the same concrete row type and fully loaded constraint fields; a projected row must be mapped by its caller first. Use WithShallow(true): nested rows require independently matched previous rows, not positional reuse. This option never infers identity from candidate values or presence markers.
func WithSetMarker ¶ added in v0.7.1
func WithSetMarker() Option
func WithShallow ¶ added in v0.15.0
WithShallow with shallow option
func WithTransaction ¶ added in v0.26.0
WithTransaction executes constraint reads in the caller's transaction. Validation never commits, rolls back, or opens a replacement transaction.
type Options ¶
type Options struct {
CheckUnique bool
CheckRef bool
Location string
Shallow bool
MaxPlaceholders int
SetMarker *option.SetMarker
CandidatePolicies []CandidatePolicy
Previous interface{}
// contains filtered or unexported fields
}
func NewOptions ¶
func NewOptions() *Options
type Reference ¶ added in v0.26.0
Reference identifies an exact compiled reference constraint. Schema is the declared RefDb, including an empty value; Field is the canonical Go name.
type Validation ¶
func (*Validation) AppendNotNull ¶ added in v0.5.1
func (e *Validation) AppendNotNull(path *Path, field, msg string)
func (*Validation) AppendRef ¶ added in v0.5.1
func (e *Validation) AppendRef(path *Path, field string, value interface{}, msg string)
func (*Validation) AppendUnique ¶ added in v0.5.1
func (e *Validation) AppendUnique(path *Path, field string, value interface{}, msg string)
func (*Validation) Error ¶ added in v0.5.1
func (e *Validation) Error() string
func (*Validation) String ¶ added in v0.5.1
func (e *Validation) String() string