Aller au contenu principal

ERROR_MESSAGES_COMPOSITION

const ERROR_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

TRADE-OFF

Direct strings provide better performance but limit tree-shaking compared to individual function exports. Bundle size impact is minimal (~1-2KB).