interface SanitizationRules
Since 0.1.0

Configuration for sanitizing a string value.

All options are optional and composable. When multiple options are enabled they are applied in a fixed, deterministic order: trim → case → pattern → stripTags → htmlEncode → maxLength.

Properties

optional
htmlEncode: boolean

Encode HTML entities (<, >, &, ", ').

optional
stripTags: boolean

Remove all HTML tags.

optional
allowedTags: string[]

Keep only the listed tag names (implies stripTags for non-listed tags).

optional
maxLength: number

Truncate the string to this many characters (applied after other transforms).

optional
pattern: RegExp

Replace the entire string with an empty string if it does not match.

optional
trim: boolean

Trim leading and trailing whitespace.

optional
toLowerCase: boolean

Convert the string to lowercase.

optional
toUpperCase: boolean

Convert the string to uppercase.

Usage

import { type SanitizationRules } from "validation-plugin/src/index.ts";