# `Statifier.Validator.Checks.Script`
[🔗](https://github.com/riddler/statifier-ex/blob/v2.6.0/lib/statifier/validator/checks/script.ex#L1)

Spec 5.8.2: "A conformant SCXML document MUST specify either the 'src'
attribute or child content, but not both." The `src`-and-content pair is
unreachable through this codebase's lowering (`Statifier.Lowering.
Builders.build_script/2` already refuses to build a struct when `src` is
written, per ADR-0026 decision 2 - `src` is rejected regardless of any
child text), so this check has exactly one remaining job: a `<script>`
with **neither** `src` nor non-blank text is an empty script, which the
spec's MUST also forbids. Reports `{:script_no_src_or_text}` at the
`<script>`'s own element span.

**Whitespace-only text is not text.** `Statifier.Parser.DOM.text/1`
concatenates `<script>`'s direct text children verbatim and untrimmed, so
a pretty-printed `<script>\n  </script>` carries a `text` of `"\n  "`.
That is source formatting, not a payload - the same rule
`Checks.Assign.blank?/1`, `Checks.Content.blank?/1`, and
`Checks.Data.blank?/1` already follow.

This check walks every state's own `onentry`/`onexit` blocks, every
state's own transitions (both plain and a `:history` state's default),
every state's `<initial>` element's own transition - the same three
places `Checks.Assign` walks - descending into `<if>` branches and
`<foreach>` bodies the same way, plus `document.scripts` for the
top-level `<script>` children a state walk cannot reach at all
(ADR-0026 Decision 7).

# `check`

```elixir
@spec check(
  document :: Statifier.Document.t(),
  context :: Statifier.Validator.Context.t()
) :: [
  Statifier.Validator.Error.t()
]
```

Walks every `<script>` reachable through a state's `onentry`/`onexit`
blocks, its own (and its `<initial>` element's) transitions, and
`document.scripts`, and returns a `:script_no_src_or_text` error for each
one whose text is blank - `src` is already unreachable in a struct
lowering ever built (see the moduledoc). Returns `[]` when every
`<script>` in the document carries non-blank text.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
