Documentation menuAPI
API
All exports of @sweberdev/inverse.
Validation
validateWithdrawal(input),validateCancellation(input),validate(kind, input): return{ ok: true, value }or{ ok: false, errors: [{ field, code }] }. Codes:required,email,too_long,date,type.
Records and receipts
createRecord(kind, data, { locale?, now?, id?, endsAt? })createReference(kind): random reference such asW-7K3QX9PDrenderReceipt(record, { company, timeZone?, messages? }):{ to, subject, text, html }declarationText(record, { company?, timeZone?, messages? }): plain-text copy for the downloaddeclarationFields(kind, data, locale?, messages?): label/value pairs for your own review stepformatDateTime(iso, locale, timeZone?),formatDate(isoDate, locale)
Deadlines
withdrawalDeadline({ start, informed?, isHoliday? }): last day of the withdrawal periodisWithinWithdrawalPeriod({ start, at?, timeZone?, informed?, isHoliday? })contractEndDate({ received, notice, termEnd?, requested? })addPeriod(date, { days?, weeks?, months? }),nextWorkingDay(date, isHoliday?),toIsoDate(date, timeZone?)
Handler
createInverseHandler(options):(request: Request) => Promise<Response>handleDeclaration(body, options): same logic for frameworks without Fetch APIHONEYPOT_FIELD
Texts
getMessages(locale, overrides?),messages,locales,isLocale(value),format(template, values)
Page check
checkUrl(url, kinds?, init?),checkHtml(html, kinds?),extractControls(html),checkControls(controls, kinds)