Built-in Processors
A reference for all built-in value processors available via $keyword syntax.
| Processor | Description |
|---|---|
$abs | Returns the absolute value of a number. |
$all | A constraint that checks whether all the provided processors return a defined value. |
$alpha | Validates that a string contains only alphabetic characters (a-z, A-Z). No spaces, numbers, punctuation, or special char |
$alphanum | Validates that a string contains only alphanumeric characters (A-Z, a-z, 0-9). No spaces, punctuation, or special charac |
$and | A constraint that checks whether all the provided processors return a truthy value. |
$any | A constraint that checks whether any of the provided processors return a defined value. (Not to be confused with the unr |
$array | Attempt to normalize the input value as an array. |
$assert | Require that the provided processor returns a truthy value; return original input. Throws a constraint exception if not |
$base64 | Validates that a string is properly formatted Base64 encoded data. Checks for valid Base64 character set (A-Z, a-z, 0-9, |
$base64-decode | Decodes a Base64-encoded string to a Buffer. Throws if the input is not a string. |
$base64-encode | Encodes a Buffer to a Base64 string. Throws if the input is not a Buffer. |
$buffer | Converts a value to a Node.js Buffer. Accepts: - Buffer — passed through unchanged - string — decoded from Base64 via B |
$camel-case | Converts a string value to camelCase format. Words are identified by spaces, hyphens, underscores, or case changes. The |
$capitalize | Capitalizes the first letter of each word, separated by spaces. Words are split on non-alphanumeric boundaries (spaces, |
$cardnum | Validates a payment card number (PAN) using the Luhn algorithm and normalizes its formatting based on the detected card |
$ceil | Rounds a numeric value up to the nearest integer or specified decimal precision. Non-numeric values are passed through u |
$check | This is a conditional operator that evaluates a predicate for truthiness. |
$clamp | Constrains a number to a [min, max] range by returning the nearest boundary when the value falls outside. Unlike $range |
$collapse | Collapses runs of whitespace within a string to a single space, and trims leading and trailing whitespace. Useful for no |
$compact | Strips common formatting characters from a string: whitespace, hyphens, dots, parentheses, and forward slashes. Useful f |
$compile | Compiles a Schema (or CompiledSchema) into a CompiledSchema ready for use in value processing. If a schema argument is p |
$concat | Returns a new array with the specified values appended to the input array. Throws SchemaError at compile time if no argu |
$constant-case | Converts a string to CONSTANT_CASE format (uppercase letters with underscores). Safe to use in normalize phase (non-thro |
$date | Normalize the input value as a Date. Accepts strings, numbers, Date instances, and date-field objects produced by $date |
$date-object | Expands a Date into a plain object with named calendar fields. |
$date-range | Validates that a date value falls within the specified range (inclusive). Can specify minimum, maximum, or both bounds. |
$defined | Allow any value, as long as it's defined. |
$directory | Validates that a path exists on the filesystem and is a directory (not a file). This is an async processor that performs |
$each | Applies a processor to each element of an array. The processor can be any valid processor specification (RegExp, functio |
$email | Validates that a string matches a practical email address format (local-part@domain.tld). |
$entries | Returns the enumerable own properties of an object as an array of [key, value] pairs, matching the output of Object.entr |
$eq | Do a deep equality check between the value and the provided constraint value. |
$exclusive | A constraint that checks whether exactly one of the provided processors returns a truthy value. |
$executable | Validates that a file path points to an executable file by checking execute permissions. This is an asynchronous process |
$file | Validates that a path exists in the filesystem and is a file (not a directory or other type). Performs an asynchronous f |
$file-size | Validates that a file's size falls within the specified range. Accepts size constraints in bytes and checks the file's m |
$filter | Runs a processor on each element of the input array, keeping elements for which the processor succeeds and returning the |
$find-schema | Find a schema in the schema hierarchy based on a dotted path. Returns the current schema by default. The provided path |
$first | An operator that returns the first defined value successfully returned from a sequence of processors. |
$flatten | Returns a new array with sub-array elements flattened to the specified depth. Throws if the input is not an array. |
$floor | Rounds a numeric value down to the specified number of decimal places. Non-numeric values are passed through unchanged. |
$gate | This is a conditional operator that evaluates a predicate for whether it returns a defined value. |
$get | Extracts a value from the input using a dot-separated path (for objects) or a numeric index (for arrays). Does not requi |
$group-by | Groups an array of objects by a key, returning an object whose values are arrays of elements that share that key value. |
$has-prefix | Check that the provided string value starts with the prefix value |
$has-suffix | Check that the provided string value ends with the suffix value |
$hex | Validates that a string contains only valid hexadecimal characters (0-9, a-f, A-F). Does not require or validate a "0x" |
$hostname | Validates that a string matches valid hostname format according to RFC 1123. Hostnames must start and end with alphanume |
$http-url | Validates that a string is a valid HTTP or HTTPS URL. Uses the URL Web API for validation and specifically requires the |
$if | This is a conditional operator that evaluates a predicate for truthiness. |
$in | Validates that a value is included in an allowed list of values. Uses strict equality (===) for comparison. |
$index-by | Groups an array of objects by a unique key, returning an object whose value is the single array element value that has t |
$input | Returns the input value passed to the processor. Acts as a declarative "pass-through". Useful for passing the input to |
$instanceof | Validates that the input is an instance of the specified constructor. |
$integer | Validates that a numeric value is an integer (no fractional part). Input must already be a number; use $number in a prio |
$invoke | Calls a provided processor and passes it arguments (if any). |
$ipv4 | Validates that a string is a valid IPv4 address in dotted-decimal notation. |
$ipv6 | Validates that a string is a properly formatted IPv6 address. Supports all standard notation formats including full, com |
$is-array | Validates that the input is a valid array. |
$is-buffer | Validates that the input is a Node.js Buffer. |
$is-date | Validates that the input is a valid date. |
$is-number | Validates that the input is a valid number. |
$is-object | Validates that the input is a valid object (and not null!) |
$is-string | Validates that the input is a valid string. |
$join | Join the input array elements into a string using the provided separator. |
$json | Validates that a string contains valid JSON that can be parsed by JSON.parse(). The processor does not modify the input |
$json-decode | Parses a JSON string into a value. Throws if the input is not a string or is not valid JSON. |
$json-encode | Serializes any value to a JSON string. |
$kebab-case | Converts a string to kebab-case format (lowercase words separated by hyphens). Safe to use in normalize phase (non-throw |
$keys | Returns the enumerable own property keys of an object as an array of strings. Throws if the input is not a plain object. |
$length | Validates that the length of a string or array falls within specified bounds (inclusive). Can specify minimum, maximum, |
$lookup | Uses the pipeline value as a key to look up a corresponding value from the argument collection. This is the inverse of $ |
$lowercase | Converts a string value to lowercase. Safe to use in normalize phase (non-throwing). |
$map | Polymorphic map operator. Applies a processor to each element of an array, or to each value of a plain object. Returns a |
$match | Operator that executes a RegExp match against a string input and returns the extracted result. Non-string values are pas |
$matches | Constraint that tests the string representation of the input against a RegExp. Throws a ConstraintError if the input doe |
$max | Returns the maximum value from an array of numbers. Returns undefined for an empty array. |
$merge | Merges the argument object into the input object (shallow). The argument fields take precedence over same-named fields i |
$merge-deep | Recursively deep-merges the argument object into the input object, returning a new object. Nested plain objects are merg |
$metadata | Extracts named metadata from a schema, either from the current schema or a parameter. |
$min | Returns the minimum value from an array of numbers. Returns undefined for an empty array. |
$negative | Validates that a numeric value is negative (less than 0). Input must already be a number; use $number in a prior normali |
$never | Inverts a processor - Returns the input if the wrapped processor throws or returns an undefined value. Throw a constrain |
$non-empty | Validates that a string, array, or object is not empty. For strings, the value must contain at least one non-whitespace |
$normalize | Normalize the incoming value according using the provided schema |
$not | Inverts a processor result - returns true if the wrapped processor throws or returns a falsey value. Throw a constraint |
$number | Validates and coerces values to numbers. Accepts numeric strings, integers, and floats. Rejects NaN, Infinity, and non-n |
$numeric | Validates that a string contains only numeric digits (0-9). The value is coerced to a string before validation, so numbe |
$object | Attempts to normalize the input value as an object. |
$omit | Returns a new object or dense array with the specified keys/indices removed. Keys not present in the input are silently |
$one | A constraint that checks whether exactly one of the provided processors returns a defined value. |
$or | A constraint that checks whether any of the provided processors return a truthy value. |
$pad | Pads a string to a minimum width. |
$parallel | Applies an array of processors concurrently to the same input value, returning an array of all results in the same order |
$pascal-case | Converts a string value to PascalCase format (first letter of each word capitalized, no separators). Safe to use in norm |
$phone | Validates and normalizes a phone number string. |
$pick | Returns a new object or dense array containing only the specified keys/indices from the input. Keys not present in the i |
$pipeline | Executes a sequence of processors in order, passing the output of each processor as input to the next. The final process |
$port | Validates that a value is a valid TCP/UDP port number (1-65535). Accepts numeric values or strings that can be converted |
$positive | Validates that a numeric value is positive (greater than 0). Input must already be a number; use $number in a prior norm |
$pow | Raises a number to a power. |
$process | Process the incoming value according to the provided schema |
$property | Extracts a named property value from an object. This operator is useful for accessing nested properties or extracting sp |
$range | Validates that a numeric value falls within the specified range (inclusive). Can specify minimum, maximum, or both bound |
$reachable | Validates that a hostname is reachable by performing a DNS lookup. This is an asynchronous processor that checks if the |
$readable | Validates that a file or directory path exists and has read permissions for the current process. Performs an asynchronou |
$reference | Returns the value at the referenced path (relative to the current schema) in the target data, or undefined if not set. |
$replace | Replaces occurrences of a pattern in a string. |
$require | Require that the provided processor returns a defined value; return the original input if so. Throws a constraint error |
$reverse | Returns a new array with elements in reverse order. Non-mutating. Throws if the input is not an array. |
$round | Rounds a numeric value to the nearest integer or to a specified number of decimal places. Safe to use in normalize phase |
$semver | Validates that a string is a valid semantic version per the semver 2.0.0 spec. |
$sort | Returns a new sorted array. Non-mutating. Numbers are compared numerically; all other values are compared lexicographica |
$split | Stringify the input and split on the provided separator, returning an array. |
$sqrt | Returns the square root of a number. |
$string | Ensures value is a string, stringifying as necessary. Everything other than null and undefined can be converted. |
$substring | Extracts a portion of a string by start index and optional length. |
$sum | Returns the sum of an array of numbers. Returns 0 for an empty array. |
$target | Returns the target value passed to the processor (value being built relative to the root). (Note: may return undefined o |
$template | Operator that interpolates a template string using properties from the input object. Placeholders use {key} syntax; do |
$title-case | Converts a string to title case, capitalizing the first letter of each significant word and leaving articles, coordinati |
$trim | Removes leading and trailing whitespace from a string value. Safe to use in normalize phase (non-throwing operator). |
$truthy | Validates that the value is "truthy". Note that the definition of what values are "truthy" mirrors the boolean schema n |
$try | This is a conditional operator that evaluates a predicate for whether it throws/rejects. |
$type | Returns the type name of the input value as a string. Unlike the $is-* constraint family, this operator produces the typ |
$unique | Returns a new array with duplicate values removed, preserving insertion order of first occurrences. Uses identity-based |
$uppercase | Converts a string value to uppercase. Safe to use in normalize phase (non-throwing). Non-string values are coerced to st |
$url | Validates that a string is a valid URL and normalizes it to canonical form. Uses the WHATWG URL Standard for validation |
$url-decode | Decodes a percent-encoded URL string. |
$url-encode | Percent-encodes a string for safe use as a URL component (query param value, path segment, etc.). Encodes all characters |
$uuid | Validates that a string matches valid UUID format (versions 1-5). UUIDs must follow RFC 4122 format: 8-4-4-4-12 hexadeci |
$values | Returns the enumerable own property values of an object as an array. Throws if the input is not a plain object. |
$when | This is a conditional operator that evaluates a predicate for whether it returns a defined value. |
$writable | Validates that a file system path is writable by checking write permissions. If the path does not exist, validates that |