Schemallic uses three protocols to decouple interface from implementation:
| Protocol | Namespace | Purpose |
|---|---|---|
SchemallicConverter | schemallic.converter.protocol | Schema -> Malli conversion |
SchemallicRegistry | schemallic.internals.def-macro.protocol | Macro-time schema storage |
CoercionTransformer | schemallic.transforms.coercion | Malli encode/decode/coerce transformer |
Why protocols?
All three protocols decouple interface from implementation. schemallic.converter.core implements SchemallicConverter and schemallic.internals.* consumes it; the internals depend on the protocol, not the concrete implementation. SchemallicRegistry keeps macro-time storage behind an interface.
SchemallicConverter - swap conversion strategies (e.g., stricter validation, logging)SchemallicRegistry - swap storage backends (default atom registry today; custom backends are possible)CoercionTransformer - swap the transformer used for encoding, decoding and coercionEach protocol ships with a default implementation (default-converter, default-registry, default-coercion-transformer) and thin wrapper functions (convert, store-schema, lookup-schema, build-coercion-transformer) that operate on the default instance. Users interact through the wrappers; the protocols are there for extensibility.
| Suffix | Meaning | Examples |
|---|---|---|
? | Predicate — returns boolean | malli-schema?, map-of-schema?, literal-value? |
* | Internal helper — not part of public API | handle-map*, collect-leaf-types*, count-max-depth* |
-> | Conversion — transforms A to B | schema->malli, key->depth, literal->malli |
! | Mutation — side-effectful/destructive variant | store! in converter/cache.clj (cache-only mutation) |
| Style | Folders | Role |
|---|---|---|
| Plural | checks/, internals/, props/, transforms/, types/ | Foundational — collections of helpers, predicates and utilities consumed by the modules below |
| Singular | comparator/, converter/, generator/, operator/ | Composed modules — each represents a single named capability, built on top of the plural layers |
| Singular support | error/ | Shared error types, messages and trail helpers |
Plural names signal "a bag of related tools". Singular names signal "one cohesive thing you call by name".
Not every ? function belongs in checks/. Domain decides placement:
| Situation | Where it lives | Example |
|---|---|---|
| Type/system predicates (Schema types, Malli shapes, base values) | checks/ | malli-schema?, schema-primitive?, atomic-value? |
| Module-internal shape detection | inside that module | regex-schema? in comparator/schema.clj, map-of-schema? in checks/schema.clj |
checks/ is organized by domain (schema.clj, malli.clj, base.clj) — predicates live there by what they check, not by how many consumers they have. Modules are free to define their own internal predicates for module-specific logic.
schemallic.unit.* = unit, schemallic.integration.schemallic.* = integration, schemallic.performance.* = performance. Selectors key off it.<topic>_test.clj. Performance: <module>_bench_test.clj. Helpers go in aux/ or helpers/.deftest names end in -test. Integration test names start with the module: core-, gen-, malli-, ops-. Property specs end -prop-test. Performance tests end -perf-test.:num-tests and :seed. Use silent-fixture.delay named <family>-sample. Label first. Column order is the contract.doseq. One testing block per label. Assert both sides: valid passes, invalid fails, form matches, overrides win.;; N/A [scope]: why. Scopes: form, macro, runtime, ops, fail.Cnn tags mark coverage groups. Fixture aliases: s schema, m malli, v valid, i invalid, f function, d data.(= nil x), (= false x).| Directory | Type | Contents |
|---|---|---|
unit/ | Module tests | 9 subdirs — aux, checks, comparator, converter, error, generator, internals, operator, transforms |
integration/ | End-to-end | 4 subdirs — core, gen, malli, ops (mirrors src/) |
performance/ | Performance tests | aux and perf suites |
fixtures/ | Test data | models*, functions*, fn_schemas, helpers |
Defined in project.clj via :test-selectors. Run with lein test :<selector> or directly as lein <selector> (e.g. lein generator, lein core, lein unit, lein performance):
Unit
| Selector | Namespace filter | Source module | Role |
|---|---|---|---|
checks | unit.checks | src/checks | Predicate / shape detection |
internals | unit.internals | src/internals | Internal helpers |
transforms | unit.transforms | src/transforms | Data transformation |
comparator | unit.comparator | src/comparator | Comparison module |
converter | unit.converter | src/converter | Conversion module |
generator | unit.generator | src/generator | Generator module |
operator | unit.operator | src/operator | Operator module |
unit | schemallic.unit | all above | (all) |
Integration
| Selector | Namespace filter | Mirrors src | Role |
|---|---|---|---|
core | integration.schemallic.core | src/core | Core e2e |
gen | integration.schemallic.gen | src/gen | Generator e2e |
malli | integration.schemallic.malli | src/malli | Malli output e2e |
ops | integration.schemallic.ops | src/ops | Operator e2e |
integration | schemallic.integration | all above | (all) |
Performance
| Selector | Namespace filter | Mirrors src | Role |
|----------|-----------------|-------------|------|
| performance | schemallic.performance | N/A | Performance tests |
Can you improve this documentation?Edit on GitHub
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |