ERROR_MESSAGES_COMPOSITION
constERROR_MESSAGES_COMPOSITION:object
Error messages constants for Kanon V3.
Centralized error messages used throughout the validation system. Messages without parameters are direct strings for optimal performance, while messages with parameters use functions for interpolation.
Type Declarationβ
string: "Expected string"β
number: "Expected number"β
boolean: "Expected boolean"β
object: "Expected object"β
array: "Expected array"β
map: "Expected map"β
set: "Expected set"β
record: "Expected record"β
minLength(): (min) => stringβ
min:
number
Returns:string
maxLength(): (max) => stringβ
max:
number
Returns:string
min(): (min) => stringβ
min:
number
Returns:string
max(): (max) => stringβ
max:
number
Returns:string
int: "Number must be an integer"β
positive: "Number must be positive"β
negative: "Number must be negative"β
email: "Invalid email format"β
url: "Invalid URL format"β
uuid: "Invalid UUID format"β
pattern(): (regex) => stringβ
regex:
RegExp
Returns:string
length(): (length) => stringβ
length:
number
Returns:string
includes(): (substring) => stringβ
substring:
string
Returns:string
startsWith(): (prefix) => stringβ
prefix:
string
Returns:string
endsWith(): (suffix) => stringβ
suffix:
string
Returns:string
lt(): (lessThan) => stringβ
lessThan:
number
Returns:string
lte(): (lessThanOrEqual) => stringβ
lessThanOrEqual:
number
Returns:string
gt(): (greaterThan) => stringβ
greaterThan:
number
Returns:string
gte(): (greaterThanOrEqual) => stringβ
greaterThanOrEqual:
number
Returns:string
multipleOf(): (multiple) => stringβ
multiple:
number
Returns:string
arrayMinLength(): (min) => stringβ
min:
number
Returns:string
arrayMaxLength(): (max) => stringβ
max:
number
Returns:string
arrayLength(): (length) => stringβ
length:
number
Returns:string
arrayUnique: "Array must contain unique values"β
setMinSize(): (min) => stringβ
min:
number
Returns:string
setMaxSize(): (max) => stringβ
max:
number
Returns:string
mapMinSize(): (min) => stringβ
min:
number
Returns:string
mapMaxSize(): (max) => stringβ
max:
number
Returns:string
objectMinKeys(): (min) => stringβ
min:
number
Returns:string
objectMaxKeys(): (max) => stringβ
max:
number
Returns:string
objectStrict(): (key) => stringβ
key:
string
Returns:string
null: "Expected null"β
undefined: "Expected undefined"β
date: "Expected date"β
bigint: "Expected bigint"β
dateMin(): (min) => stringβ
min:
Date
Returns:string
dateMax(): (max) => stringβ
max:
Date
Returns:string
dateBefore(): (before) => stringβ
before:
Date
Returns:string
dateAfter(): (after) => stringβ
after:
Date
Returns:string
bigintMin(): (min) => stringβ
min:
bigint
Returns:string
bigintMax(): (max) => stringβ
max:
bigint
Returns:string
bigintPositive: "BigInt must be positive"β
bigintNegative: "BigInt must be negative"β
union: "Value does not match any of the expected types"β
literal(): (expected, actualType) => stringβ
expected:
unknown
actualType:string
Returns:string
tuple: "Expected tuple"β
tupleLength(): (expected, actual) => stringβ
expected:
number
actual:number
Returns:string
tupleMinLength(): (expected, actual) => stringβ
expected:
number
actual:number
Returns:string
enum(): (values, actualType) => stringβ
values:
readonly unknown[]
actualType:string
Returns:string
nativeEnum(): (values, actualType) => stringβ
values:
readonly unknown[]
actualType:string
Returns:string
symbol: "Expected symbol"β
never: "This value should never exist"β
void: "Expected void (undefined)"β
missingField(): (field) => stringβ
field:
string
Returns:string
propertyError(): (field, error) => stringβ
field:
string
error:string
Returns:string
keyofExpectedOneOf(): (keys) => stringβ
keys:
string
Returns:string
coerceNumber: "Cannot coerce to number"β
coerceString: "Cannot coerce to string"β
coerceDate: "Cannot coerce to date"β
coerceBigInt: "Cannot coerce to bigint"β
coerceInvalidDate: "Invalid date"β
coerceNullToBigInt: "Cannot convert null to BigInt"β
coerceUndefinedToBigInt: "Cannot convert undefined to BigInt"β
coerceNullToDate: "Cannot convert null to Date"β
coerceUndefinedToDate: "Cannot convert undefined to Date"β
Performanceβ
Optimization: Messages without parameters are ~71% faster than arrow functions
Sinceβ
2.0.0
Direct strings provide better performance but limit tree-shaking compared to individual function exports. Bundle size impact is minimal (~1-2KB).