Module dev.metaschema.core
Package dev.metaschema.core.model.constraint
package dev.metaschema.core.model.constraint
Metaschema constraint definitions and validation framework.
This package provides the constraint system for Metaschema, which allows defining and enforcing validation rules on model instances. Constraints can restrict allowed values, enforce cardinality, ensure uniqueness, validate patterns, and establish referential integrity through index relationships.
Constraint Types
IAllowedValuesConstraint- Restricts values to a defined setICardinalityConstraint- Enforces occurrence requirements (min/max)IExpectConstraint- Validates that a condition is trueIMatchesConstraint- Validates values against regex patternsIUniqueConstraint- Ensures uniqueness of key field combinationsIIndexConstraint- Creates an index over items for referential integrityIIndexHasKeyConstraint- Verifies that references exist in an index
Validation
The DefaultConstraintValidator
provides the main entry point for validating model instances against their
constraints. Validation results are reported through
IConstraintValidationHandler
implementations.
Usage Context
Constraints can be:
- Defined inline within Metaschema definitions
- Applied externally through constraint sets
- Evaluated during content validation and data binding
- Used to generate validation rules for JSON Schema and XML Schema
- See Also:
-
ClassDescriptionAbstractConfigurableMessageConstraintBuilder<T extends AbstractConfigurableMessageConstraintBuilder<T,
R>, R extends IConfigurableMessageConstraint> Provides builder methods for the core data elements of anIConstraint.Provides builder methods for the core data elements of anIConstraint.A common implementation for a set of constraints targeted at the contents of a Metaschema module.Provides messaging for constraint violations.Provides builder methods for the core data elements of anIConstraintthat supports a custom message.AbstractTargetedConstraints<T extends IValueConstrained>Provides an base implementation for a set of constraints that target a definition using a target Metapath expression.Represents a container of rules constraining the effective model of a Metaschema assembly data instance.A set of constraints targeting aIAssemblyDefinitionbased on a target Metapath expression.Identifies that an unexpected error occurred while initializing or using constraints associated with a Metaschema-based model.Indicates a constraint validation failure.Represents an individual constraint validation issue.Implements a builder pattern for creating constraint findings.Used to perform constraint validation over one or more node items.A collection of constraints to apply to a given module identified by the module's namespace and short name.A module loading post processor that integrates applicable external constraints into a given module when loaded.A set of constraints targeting aIFieldDefinitionbased on a target Metapath expression.A validation result handler that collects the resulting findings for later retrieval using theFindingCollectingConstraintValidationHandler.getFindings()method.A set of constraints targeting aIFlagDefinitionbased on a target Metapath expression.Represents an individual enumerated value associated with anIAllowedValuesConstraint.Represents a rule requiring the value of a field or flag to match the name of one entry in a set of enumerated values.Provides a builder pattern for constructing a newIAllowedValuesConstraint.Indicates how an allowed values constraint can be extended, or if it can be.Represents a rule requiring a Metaschema assembly data instance to have elements with a minimum and/or maximum occurrence.Provides a builder pattern for constructing a newICardinalityConstraint.Represents a constraint that allows a configurable message.Represents a rule constraining the model of a Metaschema assembly, field or flag.The degree to which a constraint violation is significant.The type of constraint.A set of constraints targeted at the contents of a Metaschema module.Provides a set of callback methods used to process the result of evaluating a constraint.This interface provides an entry point for performing validations over Metapath items associated with a Metaschema model.IConstraintVisitor<T,R> Supports a visitor pattern over constraint instances.Represents a rule requiring a Metaschema assembly, field, or flag data instance to pass a Metapath-based test.Provides a builder pattern for constructing a newIExpectConstraint.A marker interface for a Metaschema model construct (i.e. assembly, field) that can be constrained using Metaschema constraints.A marker interface for a Metaschema valued construct (i.e. flag, field) that can be constrained using Metaschema constraints.Represents a rule that generates a key-based index containing references to data items found in a Metaschema data instance.Provides a builder pattern for constructing a newIIndexConstraint.Represents a rule that checks that a key generated for a Metaschema data object exists in a named index that was generated using anIIndexConstraint.Provides a builder pattern for constructing a newIIndexHasKeyConstraint.A common interface used for constraints oriented around key-based indexes.Represents a component of a key used in a key-based index.Represents a variable assignment for use in Metaschema module constraints.Represents a rule requiring the value of a field or flag to match a pattern and/or conform to an identified data type.Provides a builder pattern for constructing a newIMatchesConstraint.Represents a container of rules constraining the effective model of a Metaschema assembly data instance.Represents a rule reporting a condition when a Metaschema assembly, field, or flag data instance matches a Metapath-based test.Provides a builder pattern for constructing a newIReportConstraint.Represents a set of target constraints that apply to a given Metaschema module namespace and short name.Represents a set of constraints that target a given definition using a target Metapath expression.Represents a rule that requires all matching data items found in a Metaschema data instance to have a unique key.Provides a builder pattern for constructing a newIUniqueConstraint.Represents a container of rules constraining the effective model of a Metaschema field or flag data instance.Supports logging constraint findings to the configured Log4J2 instance.A set of constraints, which are targeted at the contents of a Metaschema module within specific contexts.A nestable context, targeted by a set of metapath expressions, to apply constraints within.Represents a set of constraints targeted at model definitions using Metapath expressions.Configuration for parallel constraint validation.The default implementation of a constraint set sourced from an external constraint resource.A set of configurable features that adjust Metaschema constraint validation behavior.A container of rules constraining the effective model of a Metaschema field or flag data instance.