Documentation
¶
Index ¶
- type AbsenceValidator
- func (v *AbsenceValidator) AutoFix(ctx *domain.ValidationContext, rule *domain.Rule, result *domain.Result) error
- func (v *AbsenceValidator) CanAutoFix() bool
- func (v *AbsenceValidator) Name() string
- func (v *AbsenceValidator) Validate(ctx *domain.ValidationContext, rule *domain.Rule) (*domain.Result, error)
- type AncestorExistsValidator
- func (v *AncestorExistsValidator) AutoFix(ctx *domain.ValidationContext, rule *domain.Rule, result *domain.Result) error
- func (v *AncestorExistsValidator) CanAutoFix() bool
- func (v *AncestorExistsValidator) Name() string
- func (v *AncestorExistsValidator) Validate(ctx *domain.ValidationContext, rule *domain.Rule) (*domain.Result, error)
- type AncestorFieldCheckValidator
- func (v *AncestorFieldCheckValidator) AutoFix(ctx *domain.ValidationContext, rule *domain.Rule, result *domain.Result) error
- func (v *AncestorFieldCheckValidator) CanAutoFix() bool
- func (v *AncestorFieldCheckValidator) Name() string
- func (v *AncestorFieldCheckValidator) Validate(ctx *domain.ValidationContext, rule *domain.Rule) (*domain.Result, error)
- type CheckDigitValidator
- func (v *CheckDigitValidator) AutoFix(ctx *domain.ValidationContext, rule *domain.Rule, result *domain.Result) error
- func (v *CheckDigitValidator) CanAutoFix() bool
- func (v *CheckDigitValidator) Name() string
- func (v *CheckDigitValidator) Validate(ctx *domain.ValidationContext, rule *domain.Rule) (*domain.Result, error)
- type CountAcrossValidator
- func (v *CountAcrossValidator) AutoFix(ctx *domain.ValidationContext, rule *domain.Rule, result *domain.Result) error
- func (v *CountAcrossValidator) CanAutoFix() bool
- func (v *CountAcrossValidator) Name() string
- func (v *CountAcrossValidator) Neighborhood(ctx *domain.ValidationContext, rule *domain.Rule) ([]NeighborRef, error)
- func (v *CountAcrossValidator) Validate(ctx *domain.ValidationContext, rule *domain.Rule) (*domain.Result, error)
- type ForeignKeyExistsValidator
- func (v *ForeignKeyExistsValidator) AutoFix(ctx *domain.ValidationContext, rule *domain.Rule, result *domain.Result) error
- func (v *ForeignKeyExistsValidator) CanAutoFix() bool
- func (v *ForeignKeyExistsValidator) Name() string
- func (v *ForeignKeyExistsValidator) Validate(ctx *domain.ValidationContext, rule *domain.Rule) (*domain.Result, error)
- type LengthValidator
- func (v *LengthValidator) AutoFix(ctx *domain.ValidationContext, rule *domain.Rule, result *domain.Result) error
- func (v *LengthValidator) CanAutoFix() bool
- func (v *LengthValidator) Name() string
- func (v *LengthValidator) Validate(ctx *domain.ValidationContext, rule *domain.Rule) (*domain.Result, error)
- type NeighborRef
- type NeighborhoodProvider
- type NoSelfCycleValidator
- func (v *NoSelfCycleValidator) AutoFix(ctx *domain.ValidationContext, rule *domain.Rule, result *domain.Result) error
- func (v *NoSelfCycleValidator) CanAutoFix() bool
- func (v *NoSelfCycleValidator) Name() string
- func (v *NoSelfCycleValidator) Validate(ctx *domain.ValidationContext, rule *domain.Rule) (*domain.Result, error)
- type ParentRankHigherValidator
- func (v *ParentRankHigherValidator) AutoFix(ctx *domain.ValidationContext, rule *domain.Rule, result *domain.Result) error
- func (v *ParentRankHigherValidator) CanAutoFix() bool
- func (v *ParentRankHigherValidator) Name() string
- func (v *ParentRankHigherValidator) Validate(ctx *domain.ValidationContext, rule *domain.Rule) (*domain.Result, error)
- type PresenceValidator
- func (v *PresenceValidator) AutoFix(ctx *domain.ValidationContext, rule *domain.Rule, result *domain.Result) error
- func (v *PresenceValidator) CanAutoFix() bool
- func (v *PresenceValidator) Name() string
- func (v *PresenceValidator) Validate(ctx *domain.ValidationContext, rule *domain.Rule) (*domain.Result, error)
- type RangeValidator
- func (v *RangeValidator) AutoFix(ctx *domain.ValidationContext, rule *domain.Rule, result *domain.Result) error
- func (v *RangeValidator) CanAutoFix() bool
- func (v *RangeValidator) Name() string
- func (v *RangeValidator) Validate(ctx *domain.ValidationContext, rule *domain.Rule) (*domain.Result, error)
- type RegexValidator
- func (v *RegexValidator) AutoFix(ctx *domain.ValidationContext, rule *domain.Rule, result *domain.Result) error
- func (v *RegexValidator) CanAutoFix() bool
- func (v *RegexValidator) Name() string
- func (v *RegexValidator) Validate(ctx *domain.ValidationContext, rule *domain.Rule) (*domain.Result, error)
- type Registry
- type RelatedFieldEqualsValidator
- func (v *RelatedFieldEqualsValidator) AutoFix(ctx *domain.ValidationContext, rule *domain.Rule, result *domain.Result) error
- func (v *RelatedFieldEqualsValidator) CanAutoFix() bool
- func (v *RelatedFieldEqualsValidator) Name() string
- func (v *RelatedFieldEqualsValidator) Validate(ctx *domain.ValidationContext, rule *domain.Rule) (*domain.Result, error)
- type RelatedFieldInSetValidator
- func (v *RelatedFieldInSetValidator) AutoFix(ctx *domain.ValidationContext, rule *domain.Rule, result *domain.Result) error
- func (v *RelatedFieldInSetValidator) CanAutoFix() bool
- func (v *RelatedFieldInSetValidator) Name() string
- func (v *RelatedFieldInSetValidator) Validate(ctx *domain.ValidationContext, rule *domain.Rule) (*domain.Result, error)
- type RelatedFieldNotEqualsValidator
- func (v *RelatedFieldNotEqualsValidator) AutoFix(ctx *domain.ValidationContext, rule *domain.Rule, result *domain.Result) error
- func (v *RelatedFieldNotEqualsValidator) CanAutoFix() bool
- func (v *RelatedFieldNotEqualsValidator) Name() string
- func (v *RelatedFieldNotEqualsValidator) Validate(ctx *domain.ValidationContext, rule *domain.Rule) (*domain.Result, error)
- type Validator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AbsenceValidator ¶
type AbsenceValidator struct{}
AbsenceValidator is the inverse of PresenceValidator: passes when the named field is empty (nil or ""), fails when it has any non-empty value. Combined with the rule's conditions block, it expresses "field X must not be set when Y" — e.g. "infraspecific epithet must be empty on a species-rank name", "gender agreement flag must not be set on a name without a terminal epithet".
func (*AbsenceValidator) AutoFix ¶
func (v *AbsenceValidator) AutoFix(ctx *domain.ValidationContext, rule *domain.Rule, result *domain.Result) error
AutoFix is not supported for absence.
func (*AbsenceValidator) CanAutoFix ¶
func (v *AbsenceValidator) CanAutoFix() bool
CanAutoFix returns false (absence cannot be auto-fixed — the safe action would be to clear the field, but that discards data the curator entered).
func (*AbsenceValidator) Name ¶
func (v *AbsenceValidator) Name() string
Name returns the validator type identifier.
func (*AbsenceValidator) Validate ¶
func (v *AbsenceValidator) Validate(ctx *domain.ValidationContext, rule *domain.Rule) (*domain.Result, error)
Validate checks that the field is empty. A missing field, nil value, or empty string all count as absent (and pass); any other value fails.
type AncestorExistsValidator ¶
type AncestorExistsValidator struct {
// contains filtered or unexported fields
}
AncestorExistsValidator walks a self-referencing parent chain from the current record and passes when at least one ancestor row satisfies the `match` predicate. Fails when the walk terminates (nil/empty parent) or hits max_depth without any match.
Handles the "must have an ancestor of rank X" family — for a subspecies looking for a genus ancestor, the walk visits species → subgenus → genus and matches on the third hop; for a root record with no parent, the chain is empty and the rule fires (which is what we want: orphaned taxa are the target). Condition-gate rules so they only fire on records where the check is meaningful (e.g. "only for species-group names").
Parameters:
parent_column string (required) — column holding parent PK.
match object (required) — {join?, field, operator, value}
where operator is equals |
not_equals | in | not_in.
Without `join`, field is read
from the ancestor row itself.
With `join`, field is read
from a joined row via one
plain equijoin — used when the
value to match lives on a
related table (e.g. taxon
ancestors carry their rank on
the associated name row).
Shape:
{"from": "<ancestor_col>",
"to": "<table>.<pk_col>"}.
max_depth int (optional, default 100) — safety cap on
walk length.
func NewAncestorExistsValidator ¶
func NewAncestorExistsValidator(pkProvider joins.PrimaryKeyProvider) *AncestorExistsValidator
NewAncestorExistsValidator builds a validator wired to a PK provider (usually the consumer's SchemaMapper). Panics on nil provider.
func (*AncestorExistsValidator) AutoFix ¶
func (v *AncestorExistsValidator) AutoFix(ctx *domain.ValidationContext, rule *domain.Rule, result *domain.Result) error
func (*AncestorExistsValidator) CanAutoFix ¶
func (v *AncestorExistsValidator) CanAutoFix() bool
func (*AncestorExistsValidator) Name ¶
func (v *AncestorExistsValidator) Name() string
func (*AncestorExistsValidator) Validate ¶
func (v *AncestorExistsValidator) Validate(ctx *domain.ValidationContext, rule *domain.Rule) (*domain.Result, error)
type AncestorFieldCheckValidator ¶
type AncestorFieldCheckValidator struct {
// contains filtered or unexported fields
}
AncestorFieldCheckValidator walks a self-referencing parent chain from the current record, finds the first ancestor matching stop_when, then asserts a comparison between a field on the current record and a field on the matched ancestor. Handles the "compare self to ancestor at rank X" family — CoL's NOMINOTYPICAL_AUTHORSHIP_DIFFERS (autonym subspecies authorship must equal parent species authorship) and PUBLISHED_BEFORE_GENUS (species year must not predate parent genus year).
Parameters:
parent_column string (required) — column holding parent PK.
stop_when object (required) — predicate that identifies the
ancestor to compare against.
Same shape as ancestor_exists's
match: {join?, field, operator,
value}. Operator ∈ equals |
not_equals | in | not_in.
assert object (required) — {self_join?, self_field,
ancestor_join?, ancestor_field,
operator}. Operator ∈ equals |
not_equals | less_than |
less_than_or_equals |
greater_than |
greater_than_or_equals.
The rule PASSES when the
comparison holds and FAILS
otherwise.
require_ancestor bool (optional, default false) — when false,
a missing ancestor is treated
as "rule not applicable" and
passes silently; when true,
missing ancestor fails.
skip_if_either_empty bool (optional, default true) — when true,
if either self or ancestor
value is nil/empty the rule
passes silently (matches the
"compatible-if-known" pattern
used by related_field_equals).
max_depth int (optional, default 100) — safety cap
on walk length.
func NewAncestorFieldCheckValidator ¶
func NewAncestorFieldCheckValidator(pkProvider joins.PrimaryKeyProvider) *AncestorFieldCheckValidator
NewAncestorFieldCheckValidator builds a validator wired to a PK provider. Panics on nil provider.
func (*AncestorFieldCheckValidator) AutoFix ¶
func (v *AncestorFieldCheckValidator) AutoFix(ctx *domain.ValidationContext, rule *domain.Rule, result *domain.Result) error
func (*AncestorFieldCheckValidator) CanAutoFix ¶
func (v *AncestorFieldCheckValidator) CanAutoFix() bool
func (*AncestorFieldCheckValidator) Name ¶
func (v *AncestorFieldCheckValidator) Name() string
func (*AncestorFieldCheckValidator) Validate ¶
func (v *AncestorFieldCheckValidator) Validate(ctx *domain.ValidationContext, rule *domain.Rule) (*domain.Result, error)
type CheckDigitValidator ¶
type CheckDigitValidator struct{}
CheckDigitValidator verifies a field's check digit against a well-known identifier algorithm. Regex covers the format; this covers the mathematical relationship the standard defines between an identifier's payload digits and its trailing check digit, which catches the two typo modes check digits are designed for (single-digit substitution, adjacent-digit transposition).
Supported algorithms:
orcid — ISO 27729 MOD 11-2; 16 chars, last is 0-9 or X.
issn — ISO 3297; 8 chars, last is 0-9 or X.
isbn10 — mod-11 with weights 10..2; last char 0-9 or X.
isbn13 — mod-10 with alternating 1,3 weights (EAN-13); 13 digits.
rorid — ROR identifier; 9 chars starting with '0', 6 base32-
Crockford payload, 2-digit ISO 7064 MOD 97-10 check.
luhn — generic mod-10 with doubling (credit-card style).
Parameters:
algorithm string (required) — one of the above.
skip_if_empty bool (default true) — empty field passes silently.
separator string (optional) — if set, the field is split on
this separator, each token is trimmed and validated
independently, and the field passes only when every
token passes. Use for fields that carry multiple
identifiers (e.g. a serial's print + electronic
ISSNs comma-joined into one col__issn value).
func NewCheckDigitValidator ¶
func NewCheckDigitValidator() *CheckDigitValidator
NewCheckDigitValidator constructs the validator. Stateless; no dependencies to inject.
func (*CheckDigitValidator) AutoFix ¶
func (v *CheckDigitValidator) AutoFix(ctx *domain.ValidationContext, rule *domain.Rule, result *domain.Result) error
func (*CheckDigitValidator) CanAutoFix ¶
func (v *CheckDigitValidator) CanAutoFix() bool
func (*CheckDigitValidator) Name ¶
func (v *CheckDigitValidator) Name() string
func (*CheckDigitValidator) Validate ¶
func (v *CheckDigitValidator) Validate(ctx *domain.ValidationContext, rule *domain.Rule) (*domain.Result, error)
type CountAcrossValidator ¶
type CountAcrossValidator struct {
// contains filtered or unexported fields
}
CountAcrossValidator counts rows in a target table whose columns match named fields on the record being validated, then range-checks the count against an expected {min, max} envelope. Generic mechanism — no schema-specific knowledge in the Go code; the rule's parameters carry the target table, the match predicates, and the expected bounds.
Parameters:
table string (required) — target table name
match list (required) — list of {target, self}
pairs. `target` is a column on the
target table; `self` is a field on
the record being validated to
supply the compared value.
exclude_self bool (default false) — when target table
equals the current table, exclude
the current row from the count via
its primary key. Ignored for
cross-table lookups.
expected object (required) — {min?: int, max?: int}
bounds. At least one of min or max
must be set. Both are inclusive.
skip_if_any_self_empty bool (default true) — pass silently when
any self field is empty/nil. Turn
off to make emptiness a match
predicate.
Common uses:
- uniqueness: `expected: {max: 0}` with `exclude_self: true`
- required-related: `expected: {min: 1}` for "at least one row exists"
- exactly-one: `expected: {min: 1, max: 1}`
func NewCountAcrossValidator ¶
func NewCountAcrossValidator(pkProvider joins.PrimaryKeyProvider) *CountAcrossValidator
NewCountAcrossValidator builds a validator wired to a PK provider (usually the consumer's SchemaMapper). The provider is only consulted when a rule opts into exclude_self; a nil provider still works for cross-table rules but panics if exclude_self is used.
func (*CountAcrossValidator) AutoFix ¶
func (v *CountAcrossValidator) AutoFix(ctx *domain.ValidationContext, rule *domain.Rule, result *domain.Result) error
func (*CountAcrossValidator) CanAutoFix ¶
func (v *CountAcrossValidator) CanAutoFix() bool
func (*CountAcrossValidator) Name ¶
func (v *CountAcrossValidator) Name() string
func (*CountAcrossValidator) Neighborhood ¶
func (v *CountAcrossValidator) Neighborhood(ctx *domain.ValidationContext, rule *domain.Rule) ([]NeighborRef, error)
Neighborhood implements NeighborhoodProvider. Returns records in the target table that share this rule's match predicates with the current record. Same-table rules exclude the current record by PK. Returns nil when the rule would skip on this record (any self field empty and skip_if_any_self_empty is true).
func (*CountAcrossValidator) Validate ¶
func (v *CountAcrossValidator) Validate(ctx *domain.ValidationContext, rule *domain.Rule) (*domain.Result, error)
type ForeignKeyExistsValidator ¶
type ForeignKeyExistsValidator struct {
// contains filtered or unexported fields
}
ForeignKeyExistsValidator asserts that a FK column on the record resolves to an existing row via a declared relation. Passes when the FK is empty (nothing to resolve) or when the relation returns a row; fails only when the FK is populated but the walk yields no target.
Ergonomic sugar over expressing the same check with related_field_equals + a presence assertion on the joined id — reads naturally at the rule call site and matches SQL semantics.
Parameters:
field string (required) — FK column on the current record. Read
once to decide whether the rule
applies (skip on empty) and to report
the offending value on failure.
relation string (required) — name of the relation to walk. The
relation must be declared in the
bundle's relations block and be
one-cardinality.
func NewForeignKeyExistsValidator ¶
func NewForeignKeyExistsValidator(resolver *joins.RelationResolver) *ForeignKeyExistsValidator
NewForeignKeyExistsValidator builds a validator over the caller's resolver. Same construction pattern as related_field_equals.
func (*ForeignKeyExistsValidator) AutoFix ¶
func (v *ForeignKeyExistsValidator) AutoFix(ctx *domain.ValidationContext, rule *domain.Rule, result *domain.Result) error
func (*ForeignKeyExistsValidator) CanAutoFix ¶
func (v *ForeignKeyExistsValidator) CanAutoFix() bool
func (*ForeignKeyExistsValidator) Name ¶
func (v *ForeignKeyExistsValidator) Name() string
func (*ForeignKeyExistsValidator) Validate ¶
func (v *ForeignKeyExistsValidator) Validate(ctx *domain.ValidationContext, rule *domain.Rule) (*domain.Result, error)
type LengthValidator ¶
type LengthValidator struct{}
LengthValidator validates string length constraints.
func (*LengthValidator) AutoFix ¶
func (v *LengthValidator) AutoFix(ctx *domain.ValidationContext, rule *domain.Rule, result *domain.Result) error
AutoFix is not supported for length validator.
func (*LengthValidator) CanAutoFix ¶
func (v *LengthValidator) CanAutoFix() bool
CanAutoFix returns false (length cannot be auto-fixed safely).
func (*LengthValidator) Name ¶
func (v *LengthValidator) Name() string
Name returns the validator type identifier.
func (*LengthValidator) Validate ¶
func (v *LengthValidator) Validate(ctx *domain.ValidationContext, rule *domain.Rule) (*domain.Result, error)
Validate checks if the field value length is within the specified range.
type NeighborRef ¶
NeighborRef points to a specific record whose validation results may be affected by a mutation to the currently-validating record. Consumers use it to propagate re-sync after a write.
type NeighborhoodProvider ¶
type NeighborhoodProvider interface {
Neighborhood(ctx *domain.ValidationContext, rule *domain.Rule) ([]NeighborRef, error)
}
NeighborhoodProvider is an optional interface for validators whose output depends on rows other than the one being validated (typically aggregates). When implemented, callers query the validator for the records whose results may have changed and re-run their validation.
Return an empty slice when the rule isn't currently applicable (e.g. self fields empty and the rule skips) — callers treat that as "no propagation needed" without an error path.
Only "new-side" neighbors are discoverable this way — records that currently match the record being validated. Records that USED to match (before the mutation changed the record's fields) are not returned; callers wanting full pre/post coverage need a pre-mutation hook to snapshot the old neighborhood.
type NoSelfCycleValidator ¶
type NoSelfCycleValidator struct {
// contains filtered or unexported fields
}
NoSelfCycleValidator walks a self-referencing parent chain from the record being validated and flags the record when its own PK appears in the reachable set — i.e. R sits on a parent-chain cycle. Applies to trees encoded as (pk, parent_pk) on the same table (taxonomies, subject hierarchies, comment threads, …).
Parameters:
parent_column string (required) — column holding the parent PK.
Table is always the current record's table;
pk column comes from the SchemaMapper.
SQL uses a recursive CTE with UNION (not UNION ALL), so cycles don't cause the query to loop forever — the reachable set converges and the outer SELECT asks "is R's PK in it?".
func NewNoSelfCycleValidator ¶
func NewNoSelfCycleValidator(pkProvider joins.PrimaryKeyProvider) *NoSelfCycleValidator
NewNoSelfCycleValidator builds a validator wired to a PK provider (usually the consumer's SchemaMapper). A nil provider is a programmer error: the validator panics rather than emit SQL with an empty column name.
func (*NoSelfCycleValidator) AutoFix ¶
func (v *NoSelfCycleValidator) AutoFix(ctx *domain.ValidationContext, rule *domain.Rule, result *domain.Result) error
func (*NoSelfCycleValidator) CanAutoFix ¶
func (v *NoSelfCycleValidator) CanAutoFix() bool
func (*NoSelfCycleValidator) Name ¶
func (v *NoSelfCycleValidator) Name() string
func (*NoSelfCycleValidator) Validate ¶
func (v *NoSelfCycleValidator) Validate(ctx *domain.ValidationContext, rule *domain.Rule) (*domain.Result, error)
type ParentRankHigherValidator ¶
type ParentRankHigherValidator struct {
// contains filtered or unexported fields
}
ParentRankHigherValidator asserts that the record's immediate parent has a taxonomically-higher rank than the record itself, per an ordered-list rank vocabulary that varies by nomenclatural code. Single-hop is sufficient — if the invariant holds pairwise through the whole tree, the classification is monotonic by induction.
rank_order is a per-code map from code id to an ordered list of rank ids. Position in the list is the ordinal; lower index means higher in the tree (kingdom is 0, subspecies is far down). Same rank id may appear at different indexes across codes — that's the whole reason the vocab is per-code.
Parameters:
parent_column string (required) — column on self holding the
parent PK.
rank_column string (required) — column carrying the rank id.
Read from self and from parent
(optionally via `join`).
code_column string (required) — column carrying the code id.
Same join semantics as rank.
join object (optional) — {"from": "<col_on_taxon>", "to":
"<table>.<pk>"}. Used when the
rank/code fields live on a
related row (in sfga they live
on the name row reached via
col__name_id).
rank_order object (required) — {code_id: [rank_id, rank_id,
...]}. Position = ordinal.
Skip conditions (all return pass):
- self has no parent
- self or parent lacks rank / code
- self and parent have different codes (a cross-code check is a different concern; skip here)
- either code isn't declared in rank_order
- either rank isn't in the code's rank list
func NewParentRankHigherValidator ¶
func NewParentRankHigherValidator(pkProvider joins.PrimaryKeyProvider) *ParentRankHigherValidator
NewParentRankHigherValidator builds a validator over a PK provider. Panics on nil provider.
func (*ParentRankHigherValidator) AutoFix ¶
func (v *ParentRankHigherValidator) AutoFix(ctx *domain.ValidationContext, rule *domain.Rule, result *domain.Result) error
func (*ParentRankHigherValidator) CanAutoFix ¶
func (v *ParentRankHigherValidator) CanAutoFix() bool
func (*ParentRankHigherValidator) Name ¶
func (v *ParentRankHigherValidator) Name() string
func (*ParentRankHigherValidator) Validate ¶
func (v *ParentRankHigherValidator) Validate(ctx *domain.ValidationContext, rule *domain.Rule) (*domain.Result, error)
type PresenceValidator ¶
type PresenceValidator struct{}
PresenceValidator checks if a field has a non-nil, non-empty value.
func (*PresenceValidator) AutoFix ¶
func (v *PresenceValidator) AutoFix(ctx *domain.ValidationContext, rule *domain.Rule, result *domain.Result) error
AutoFix is not supported for presence validator.
func (*PresenceValidator) CanAutoFix ¶
func (v *PresenceValidator) CanAutoFix() bool
CanAutoFix returns false (presence cannot be auto-fixed).
func (*PresenceValidator) Name ¶
func (v *PresenceValidator) Name() string
Name returns the validator type identifier.
func (*PresenceValidator) Validate ¶
func (v *PresenceValidator) Validate(ctx *domain.ValidationContext, rule *domain.Rule) (*domain.Result, error)
Validate checks if the field has a value.
type RangeValidator ¶
type RangeValidator struct{}
RangeValidator validates that numeric or date values fall within a specified range.
func (*RangeValidator) AutoFix ¶
func (v *RangeValidator) AutoFix(ctx *domain.ValidationContext, rule *domain.Rule, result *domain.Result) error
AutoFix is not supported for range validator.
func (*RangeValidator) CanAutoFix ¶
func (v *RangeValidator) CanAutoFix() bool
CanAutoFix returns false (range cannot be auto-fixed).
func (*RangeValidator) Name ¶
func (v *RangeValidator) Name() string
Name returns the validator type identifier.
func (*RangeValidator) Validate ¶
func (v *RangeValidator) Validate(ctx *domain.ValidationContext, rule *domain.Rule) (*domain.Result, error)
Validate checks if the field value is within the specified range.
type RegexValidator ¶
type RegexValidator struct {
// contains filtered or unexported fields
}
RegexValidator validates field values against regular expression patterns.
func NewRegexValidator ¶
func NewRegexValidator() *RegexValidator
NewRegexValidator creates a new regex validator with pattern caching.
func (*RegexValidator) AutoFix ¶
func (v *RegexValidator) AutoFix(ctx *domain.ValidationContext, rule *domain.Rule, result *domain.Result) error
AutoFix is not supported for regex validator.
func (*RegexValidator) CanAutoFix ¶
func (v *RegexValidator) CanAutoFix() bool
CanAutoFix returns false (regex cannot be auto-fixed).
func (*RegexValidator) Name ¶
func (v *RegexValidator) Name() string
Name returns the validator type identifier.
func (*RegexValidator) Validate ¶
func (v *RegexValidator) Validate(ctx *domain.ValidationContext, rule *domain.Rule) (*domain.Result, error)
Validate checks if the field value matches the regex pattern.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry manages all registered validators.
type RelatedFieldEqualsValidator ¶
type RelatedFieldEqualsValidator struct {
// contains filtered or unexported fields
}
RelatedFieldEqualsValidator compares a field on the target record against the same-or-different field on a related record reached via a named relation from the bundle's Relations catalog. Generic mechanism — no schema-specific knowledge in the Go code; the rule's parameters carry the relation name, the fields to compare, and how to treat empty values.
Parameters:
relation: string (required) — relation name in the catalog
field: string (required) — field on the record to read
related_field: string (optional) — field on the related row (defaults to field)
skip_if_either_empty: bool (default true) — pass silently when
either side is empty; otherwise treat
empty vs non-empty as mismatch
Passes when the two values compare equal, or when either side is empty and skip_if_either_empty is true (the common "compatible-if-known" pattern), or when the relation has no target row (orphan / root record).
func NewRelatedFieldEqualsValidator ¶
func NewRelatedFieldEqualsValidator(resolver *joins.RelationResolver) *RelatedFieldEqualsValidator
NewRelatedFieldEqualsValidator builds a validator wired to the caller's resolver. Consumer applications construct one resolver from the loaded bundles' Relations blocks and pass it in.
func (*RelatedFieldEqualsValidator) AutoFix ¶
func (v *RelatedFieldEqualsValidator) AutoFix(ctx *domain.ValidationContext, rule *domain.Rule, result *domain.Result) error
func (*RelatedFieldEqualsValidator) CanAutoFix ¶
func (v *RelatedFieldEqualsValidator) CanAutoFix() bool
func (*RelatedFieldEqualsValidator) Name ¶
func (v *RelatedFieldEqualsValidator) Name() string
func (*RelatedFieldEqualsValidator) Validate ¶
func (v *RelatedFieldEqualsValidator) Validate(ctx *domain.ValidationContext, rule *domain.Rule) (*domain.Result, error)
type RelatedFieldInSetValidator ¶
type RelatedFieldInSetValidator struct {
// contains filtered or unexported fields
}
RelatedFieldInSetValidator checks that a field on the related record reached via a named relation is one of a caller-supplied set of allowed values. Common pattern: "the parent taxon's rank must be one of GENUS, SUBGENUS, INFRAGENUS."
Parameters:
relation: string (required) — relation name in the catalog
related_field: string (required) — field on the related row
allowed_values: []string (required) — the set to test against
skip_if_empty: bool (default true) — pass silently when the
related row's field is empty (undeclared)
Passes when the related row's value is in allowed_values, when the related row is missing (orphan / root record), or when the related field is empty and skip_if_empty is true.
func NewRelatedFieldInSetValidator ¶
func NewRelatedFieldInSetValidator(resolver *joins.RelationResolver) *RelatedFieldInSetValidator
NewRelatedFieldInSetValidator builds a validator wired to the caller's resolver.
func (*RelatedFieldInSetValidator) AutoFix ¶
func (v *RelatedFieldInSetValidator) AutoFix(ctx *domain.ValidationContext, rule *domain.Rule, result *domain.Result) error
func (*RelatedFieldInSetValidator) CanAutoFix ¶
func (v *RelatedFieldInSetValidator) CanAutoFix() bool
func (*RelatedFieldInSetValidator) Name ¶
func (v *RelatedFieldInSetValidator) Name() string
func (*RelatedFieldInSetValidator) Validate ¶
func (v *RelatedFieldInSetValidator) Validate(ctx *domain.ValidationContext, rule *domain.Rule) (*domain.Result, error)
type RelatedFieldNotEqualsValidator ¶
type RelatedFieldNotEqualsValidator struct {
// contains filtered or unexported fields
}
RelatedFieldNotEqualsValidator is the negative counterpart of RelatedFieldEqualsValidator: it flags records whose field equals the same-or-different field on a related row, and passes when the two values differ.
Parameters:
relation: string (required) — relation name in the catalog
field: string (required) — field on the record to read
related_field: string (optional) — field on the related row (defaults to field)
skip_if_either_empty: bool (default true) — pass silently when
either side is empty; otherwise treat
empty vs non-empty as a difference
Typical use is "an X should not reuse a Y drawn from a related record" — for example a subsequent-combination name whose nomenclatural reference must not be the original combination's reference.
func NewRelatedFieldNotEqualsValidator ¶
func NewRelatedFieldNotEqualsValidator(resolver *joins.RelationResolver) *RelatedFieldNotEqualsValidator
NewRelatedFieldNotEqualsValidator builds a validator wired to the caller's resolver.
func (*RelatedFieldNotEqualsValidator) AutoFix ¶
func (v *RelatedFieldNotEqualsValidator) AutoFix(ctx *domain.ValidationContext, rule *domain.Rule, result *domain.Result) error
func (*RelatedFieldNotEqualsValidator) CanAutoFix ¶
func (v *RelatedFieldNotEqualsValidator) CanAutoFix() bool
func (*RelatedFieldNotEqualsValidator) Name ¶
func (v *RelatedFieldNotEqualsValidator) Name() string
func (*RelatedFieldNotEqualsValidator) Validate ¶
func (v *RelatedFieldNotEqualsValidator) Validate(ctx *domain.ValidationContext, rule *domain.Rule) (*domain.Result, error)
type Validator ¶
type Validator interface {
// Name returns the validator type identifier (must match rule.ValidatorType)
Name() string
// Validate executes the validation logic and returns a result
Validate(ctx *domain.ValidationContext, rule *domain.Rule) (*domain.Result, error)
// CanAutoFix returns true if this validator supports automatic fixing
CanAutoFix() bool
// AutoFix attempts to fix the validation error (only called if CanAutoFix returns true)
AutoFix(ctx *domain.ValidationContext, rule *domain.Rule, result *domain.Result) error
}
Validator defines the interface that all validators must implement. This is the core abstraction for validation logic in the use case layer.