Scan¶
Structural safety before anything else.
Scan is the first stage of every Jane pipeline. It runs before normalization, parsing, or validation, and its job is simple: detect structural hazards early, before the rest of the pipeline touches the value.
Scan never interprets, never mutates, and never enforces business rules. It’s a structural safety check — nothing more, nothing less.
Why scan exists¶
Most validation libraries jump straight into parsing or validation. That works fine for small inputs, but it breaks down the moment you’re dealing with:
- Deeply nested objects.
- Circular references.
- Unsafe Unicode.
- Malformed dates.
- Sparse arrays.
- Values that can’t be safely cloned.
- Values that can’t be safely walked.
Scan exists to protect the rest of the pipeline from these hazards.
It’s the is this safe to even look at? stage.
If scan finds something dangerous, strict mode will reject immediately. Moderate and lax modes will record the issue but continue.
What scan does¶
Scan performs three things, in this order:
-
Containment
Jane creates a safe, deeply cloned version of the input.
This ensures later stages never mutate the original value.
-
Root‑level structural checks: Scan rules run once, on the root value.
These rules detect things like:
- Circular references
- Unsafe Unicode
- Extremely deep structures
- Non‑finite numbers
- Invalid dates
- Sparse arrays
- Prototype pollution hazards
Scan rules emit events — they never change the value.
-
Path enumeration
Jane walks the raw structure to build a complete FieldPath map.
No rules run during this walk. It’s purely for path awareness.
When Scan Runs¶
Scan is controlled by policy:
scan: true: Always enabled.scan: false: Disabled.
You can also enable it explicitly:
const result = jane.value(input).scan().nonEmpty().minLength(2).run();
What Scan Never Does¶
Scan is intentionally limited. It does not:
- Normalize.
- Parse.
- Validate.
- Coerce.
- Interpret.
- Mutate.
- Walk recursively with rules.
- Change the final value.
Scan is a structural safety check. Nothing more.
How Scan Affects Decisions¶
Scan emits events with severity levels (info, warn, error, fatal).
Policy decides what to do with them:
- Strict policy: Rejects on many scan codes.
- Default (moderate) policy: Records them.
- Lax policy: Policy downgrades them.
If a scan rule emits a fatal event, the pipeline stops immediately.
This prevents unsafe values from entering later stages.
Why Scan Matters¶
Scan is one of the reasons Jane feels predictable and safe:
- Validators never have to worry about malformed structures.
- Parsers never have to handle impossible shapes.
- Normalization never has to defend itself.
- Contributors never have to write defensive code.
- Consumers get consistent behavior across all pipelines.
Scan is the quiet foundation that makes the rest of Jane feel clean.