Liking cljdoc? Tell your friends :D

Development

Source (src/)

Protocols

Schemallic uses three protocols to decouple interface from implementation:

ProtocolNamespacePurpose
SchemallicConverterschemallic.converter.protocolSchema -> Malli conversion
SchemallicRegistryschemallic.internals.def-macro.protocolMacro-time schema storage
CoercionTransformerschemallic.transforms.coercionMalli 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 coercion

Each 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.

Functions Convention

SuffixMeaningExamples
?Predicate — returns booleanmalli-schema?, map-of-schema?, literal-value?
*Internal helper — not part of public APIhandle-map*, collect-leaf-types*, count-max-depth*
->Conversion — transforms A to Bschema->malli, key->depth, literal->malli
!Mutation — side-effectful/destructive variantstore! in converter/cache.clj (cache-only mutation)

Folders Naming Convention

StyleFoldersRole
Pluralchecks/, internals/, props/, transforms/, types/Foundational — collections of helpers, predicates and utilities consumed by the modules below
Singularcomparator/, converter/, generator/, operator/Composed modules — each represents a single named capability, built on top of the plural layers
Singular supporterror/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".

Predicate Placement

Not every ? function belongs in checks/. Domain decides placement:

SituationWhere it livesExample
Type/system predicates (Schema types, Malli shapes, base values)checks/malli-schema?, schema-primitive?, atomic-value?
Module-internal shape detectioninside that moduleregex-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.

Testing (test/)

Test conventions

  • Namespace says what it is: schemallic.unit.* = unit, schemallic.integration.schemallic.* = integration, schemallic.performance.* = performance. Selectors key off it.
  • Files: <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.
  • Property specs pin :num-tests and :seed. Use silent-fixture.
  • A fixture law is one vector row in a delay named <family>-sample. Label first. Column order is the contract.
  • Drive tests with doseq. One testing block per label. Assert both sides: valid passes, invalid fails, form matches, overrides win.
  • Mark skipped cases in place: ;; 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.
  • Integration assertions compare values directly: (= nil x), (= false x).
  • Keep fixture data fixed: fixed instants, UUIDs and seeds.

Testing Structure

DirectoryTypeContents
unit/Module tests9 subdirs — aux, checks, comparator, converter, error, generator, internals, operator, transforms
integration/End-to-end4 subdirs — core, gen, malli, ops (mirrors src/)
performance/Performance testsaux and perf suites
fixtures/Test datamodels*, functions*, fn_schemas, helpers

Test Selectors

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

SelectorNamespace filterSource moduleRole
checksunit.checkssrc/checksPredicate / shape detection
internalsunit.internalssrc/internalsInternal helpers
transformsunit.transformssrc/transformsData transformation
comparatorunit.comparatorsrc/comparatorComparison module
converterunit.convertersrc/converterConversion module
generatorunit.generatorsrc/generatorGenerator module
operatorunit.operatorsrc/operatorOperator module
unitschemallic.unitall above(all)

Integration

SelectorNamespace filterMirrors srcRole
coreintegration.schemallic.coresrc/coreCore e2e
genintegration.schemallic.gensrc/genGenerator e2e
malliintegration.schemallic.mallisrc/malliMalli output e2e
opsintegration.schemallic.opssrc/opsOperator e2e
integrationschemallic.integrationall 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

Keyboard shortcuts
Ctrl+kJump to recent docs
←Move to previous article
→Move to next article
Ctrl+/Jump to the search field
× close