Language Validator
The language-validator policy checks input text against language allow or deny lists. Use apply_to: input. The gateway does not enforce output language.
Supported detected languages
At this time, the detector recognizes these ISO-like codes:
enesfrdezhjakoarptru
Configuration
pack:
name: language-validator
version: "1.0.0"
enabled: true
policies:
chain:
- language-validator
policy:
language-validator:
allowed_languages:
- en
- fr
denied_languages: []
min_confidence: 0.5
action: block
apply_to: input
Fields
| Field | Type | Description | Default |
|---|---|---|---|
allowed_languages | string[] | Allowed language codes. A non-empty list rejects a detected code that is not in the list. | [] |
denied_languages | string[] | Denylist of detected language codes. Used only when allowed_languages is empty. | [] |
min_confidence | number | Minimum confidence for an action. The gateway allows a result below this value. | 0.5 |
action | "block" | "warn" | block returns a block verdict. warn allows the request and records a warning-style cause code. | "block" |
apply_to | "input" | "output" | "both" | Set input explicitly. both checks input only. output does not enforce language. | runtime default: "input" |
How it works
- Text selection: The gateway makes one string from
userandsysteminput messages. - Detection: Local Unicode-block and trigram rules detect the language.
- Confidence check: The gateway allows detections below
min_confidence. - Policy check: The gateway compares the language with
allowed_languagesordenied_languages. - Verdict:
blockreturns a block verdict.warnreturns allow with a warning cause.
Correct examples
English-only input gate
pack:
name: english-only
version: "1.0.0"
enabled: true
policies:
chain:
- language-validator
policy:
language-validator:
allowed_languages:
- en
min_confidence: 0.6
action: block
apply_to: input
Use warn on denied languages without blocking
pack:
name: routing-observability
version: "1.0.0"
enabled: true
policies:
chain:
- language-validator
policy:
language-validator:
denied_languages:
- ja
- ar
min_confidence: 0.4
action: warn
apply_to: input
Important limitations
- Output language enforcement is not supported. Use
apply_to: input.outputskips checks, andbothchecks input only. - Streaming startup rejects
apply_to: outputandapply_to: bothwithstreaming.policy_cannot_enforce. - The active lint schema shows a different default. Always set
apply_to: input. - The detector only recognizes the supported language set listed above.
- Mixed-language or short text can have a result below
min_confidence. The gateway allows this text.
Best practices
- Prefer
allowed_languagesfor strict input control. - Start with
action: warnif traffic measurement is necessary before block enforcement. - Add
prompt-injectionorpii-detectorwhen their different input controls are necessary.
Next steps
- Prompt Injection Detection — Protect the input boundary first
- PII Detector — Sanitize sensitive data after language checks
- Safety Filter — Response safety controls