Decorators
@system-inc/base-foundation · 515c140 · 33 symbols
@VerifyArrayMaxSize
Validates that an array property contains no more than the given number of elements.
@VerifyArrayMinSize
Validates that an array property contains at least the given number of elements.
@VerifyArrayUnique
Validates that an array property contains only unique values.
@VerifyBy
Creates a property decorator for a validation rule.
The returned factory is callable (VerifyIsEmail() / VerifyMaxLength(255))
and also exposes a .check() predicate for ad-hoc use:
Usage:
@VerifyIsArray
Validates that the property is an array.
@VerifyIsBoolean
Validates that the property is a boolean.
@VerifyIsCountryCode
Validates that a value is a real ISO 3166-1 country code. Membership is checked against the complete list (249 entries per format).
Formats:
'alpha2'(default) — two uppercase letters (US,DE,GB)'alpha3'— three uppercase letters (USA,DEU,GBR)'numeric'— three digits as a string, zero-padded (840,276,826)
The ISO list is stable (1–2 updates per decade); the embedded data
lives in ./internal/Iso3166Codes.ts and can be resynced from the
ISO Maintenance Agency when needed.
@VerifyIsDate
Validates that the property is a valid Date instance.
@VerifyIsDefined
Validates that the property is neither null nor undefined.
@VerifyIsDomain
Validates that the property is a domain name such as example.com
or api.example.co.uk.
@VerifyIsEmail
Validates that the property is a plausible email address.
Pragmatic rather than strictly RFC 5322 — layer VerifyStringMatches
or VerifyBy for stricter needs.
@VerifyIsEnum
Validates that a value is one of a defined enumeration.
"Enumeration" here is the general sense — any fixed set of allowed
values — not strictly a TypeScript enum. Accepts:
- A TypeScript
enum:@VerifyIsEnum(Status) - A
constobject:@VerifyIsEnum({ A: 'a', B: 'b' } as const) - A plain array:
@VerifyIsEnum(['Contact', 'Article'])
@VerifyIsInt
Validates that the property is an integer.
@VerifyIsIP
Validates that the property is an IPv4 or IPv6 address. Pass a version to accept only one family.
@VerifyIsLocale
Validates that a value is a well-formed BCP 47 language tag.
Uses the built-in Intl.Locale constructor, which parses the full
BCP 47 grammar (language, script, region, variants, extensions).
Examples that pass: "en", "en-US", "zh-Hans-CN", "ja-JP-u-ca-japanese".
Examples that fail: "not-a-locale", "english", "en_US" (underscore).
This is real validation — the runtime does the parsing, so there's no shipped allowlist to maintain.
@VerifyIsNotEmpty
Validates that the property is not empty — rejects null,
undefined, '', [], and {}. Numbers (including 0),
booleans, and class instances are never empty.
@VerifyIsNumber
Validates that the property is a finite number.
@VerifyIsObject
Validates that the property is an object (not an array and not
null).
@VerifyIsOptional
Marks the property as optional. When the value is null or
undefined, every other rule on the property is skipped.
The rule itself always passes — it serves as a sentinel read by the ValidationEngine.
@verifyIsPhoneNumber
Standalone validator — exposed for callers that need to run the phone-number check outside a decorator (e.g. in a service method).
@VerifyIsPhoneNumber
Validates that the property is a phone number in an accepted format (E.164 and North American formats by default).
@VerifyIsString
Validates that the property is a string.
@VerifyIsTimeZone
Validates that the property is a valid IANA time zone name such as
America/Denver.
@VerifyIsUrl
Validates that the property is a valid http: or https: URL.
@VerifyIsUUID
Validates that the property is a UUID of the given version
(1–8, or 'all' for any version).
@VerifyLength
Validates that a string or array property's length is at least
min and, when given, at most max (inclusive).
@VerifyMax
Validates that a number property is not greater than the given maximum.
@VerifyMaxDate
Validates that a Date property is on or before the given maximum.
@VerifyMaxLength
Validates that a string or array property is at most the given length.
@VerifyMin
Validates that a number property is not less than the given minimum.
@VerifyMinDate
Validates that a Date property is on or after the given minimum.
@VerifyMinLength
Validates that a string or array property is at least the given length.
@VerifyStringMatches
Regex match against a string value. Accepts either a RegExp
or a pattern string; strings are promoted to new RegExp(pattern, modifiers).