Skip to content

Add :spec support to SequenceOfType and SetOfType#58

Merged
gbuisson merged 5 commits intomasterfrom
add-spec-support-collection-types-v2
Mar 26, 2026
Merged

Add :spec support to SequenceOfType and SetOfType#58
gbuisson merged 5 commits intomasterfrom
add-spec-support-collection-types-v2

Conversation

@ereteog
Copy link
Contributor

@ereteog ereteog commented Mar 11, 2026

Summary

  • Adds :spec predicate support to SequenceOfType and SetOfType in flanders.spec, enabling custom validation (e.g., max collection length) on sequence and set fields
  • Uses s/and-spec-impl instead of eval to correctly handle closures as spec predicates (e.g., pred/max-len from CTIM)
  • Adds comprehensive tests for both types with inline predicates, closures, and without spec (backward compatibility)

Context

Needed by XDR-46972 to add size constraints to CTIM collection fields.

Related ctim#483
Related ctia#1514

Test plan

  • lein test passes — all existing + new tests green
  • Deploy as 1.1.1-SNAPSHOT to Clojars (already done)
  • Verify CTIM can use (f/seq-of ... :spec (pred/max-len N)) with this version

When provided, the :spec predicate is combined with s/and on the
s/coll-of spec, using s/and-spec-impl to avoid closure serialization
issues with eval. Follows the same pattern as MapType.

This enables adding size constraints to collection fields, e.g.:
  (f/seq-of f/any-str :spec (pred/max-len 1000))

Backward compatible: no :spec means existing behavior unchanged.
@ereteog ereteog marked this pull request as draft March 16, 2026 17:00
@ereteog ereteog marked this pull request as ready for review March 16, 2026 17:00
gbuisson and others added 2 commits March 26, 2026 14:45
ubuntu-20.04 runners were retired by GitHub, causing all CI jobs to
timeout after 24h waiting for a runner.
The ocsf-test/test-all-ocsf-versions test requires Docker and external
repos (ocsf-server, ocsf-schema) which are not available in CI.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@gbuisson gbuisson merged commit c1681b9 into master Mar 26, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants