Highlights
- Added built-in save-time attribute validation to
@Attribute: numericmin/max, stringminLength/maxLength/regex, and fixedminDate/maxDate. - Extended runtime schema metadata and pure-code test models to reproduce supported rules with Core Data's native predicates, error codes, and persistent attribute keys.
- Added generation and source/model validation for these rules in
cde-tool. Regex comparison decodes Swift string literals and compares the exact ICU pattern, accepting escaped/raw spellings inconformancemode. - Fixed generated
@NSModelActorcleanup referencing Observation types on older deployment targets. Ordinaryinit(container:)remains available across the library's supported platforms.
Usage and Boundaries
@Attribute(persistentName: "name", minLength: 1, maxLength: 80, regex: #".*\S.*"#)
var title: String?
@Attribute(min: 0, max: 255)
var count: Int64?Production .xcdatamodeld files remain the schema authority: annotations do not modify loaded production models. Update the model and source together, then run cde-tool validate.
Rules currently require .default storage and supported literal arguments. Regex uses ICU strings, not Swift Regex literals. exact mode additionally enforces canonical generated text. Changed patterns are reported even when two expressions might accept the same inputs; rule differences are not automatically fixed.
Unsupported declared rules and model predicates/warnings produce diagnostics. Pure-code models cannot discover constraints that only exist in the production model; use cde-tool validate and real-model integration tests to cover those cases.
See the Attribute Validation Guide and Observation Guide.
Compatibility
The library's minimum deployment targets are unchanged. Existing consumers can continue using their current declarations.
The optional prebuilt cde-tool asset is for macOS on Apple silicon (arm64), requires macOS 12+, and is unsigned. Other environments can build the CLI from source. version.json records the source commit and toolchain; SHA256SUMS covers the binary archive and metadata.
Validation
- 357 tests passed in the public release checkout, including save-time comparisons against a real
momc-compiled model on SQLite. - Generated-model conformance/exact validation, independent downstream build/run, and the low-deployment-target actor fixture passed.