Useful Utils โ
mono-utils bundles the small, fiddly helpers you'd otherwise rewrite on every screen โ form validation, notifications, list add/update/remove, OData filters, JSON parsing โ into one place, tested and consistent. They're exposed through useMonoUtility (imported from mono-utils/runtime), so you import them all from one place.
Reach for these before writing custom code (Rule 13 in Template Rules). If a helper here covers what you need, use it; don't reimplement it.
How to use โ
Import useMonoUtility from mono-utils/runtime โ the same entry app code already uses for monoJwt / createMono / monoState โ and destructure what you need:
ts
import { useMonoUtility } from 'mono-utils/runtime'
const { validateAllSchema, notif, replacerData } = useMonoUtility()A Host/Remote can still re-spread it into its own local composable (src/composables/use-helper.ts) if it wants a single project-wide helper; that composable just spreads useMonoUtility().
numColTemplate isn't here
useMonoUtility re-exposes everything except numColTemplate (a DevExtreme DataGrid auto-numbering column), which is grid-specific. On the rare screen that needs it, reach for the full helper via useUtils (also re-exported from mono-utils): import { useUtils } from 'mono-utils/runtime'; const { numColTemplate } = useUtils().
Notifications โ
| Helper | Signature | Description |
|---|---|---|
notif | notif(options): Promise<void> | One unified notification for success / info / warning / error / promise. Optional routing + redirect; non-error toasts auto-dismiss (~3s). |
Render notifications in your app shell with MonoNotivue.
Schema validation (Yup) โ
Powered by Yup โ an optional dependency. See the Yup addon for the schema + error-object pattern and setup.
| Helper | Signature | Description |
|---|---|---|
validateAllSchema | validateAllSchema({ schema, input, error }, cb?): Promise<boolean> | Validate a whole form object against a Yup schema (nested objects supported). Fills the error object with per-field messages + validity. |
validateSchema | validateSchema({ schema, field, input, error }, cb?): Promise<boolean> | Validate a single field. Updates that field's message + valid flag in the error object. |
validateAllSchemaCheck | validateAllSchemaCheck(error): boolean | Quick check โ true if any field in the error object is currently invalid. |
clearSchemaValidation | clearSchemaValidation({ error }) | Recursively reset all errors โ valid = true, message = ''. |
Data manipulation & filtering โ
| Helper | Signature | Description |
|---|---|---|
replacerData | replacerData({ fn, type, item, key, items }) | Add / update / remove a row in an array or a DevExtreme DataSource. type picks the target โ data (array) or datasource; fn is the op โ push (prepend), replace (upsert), or remove. Strips @odata.context / @odata.url metadata on the datasource path. |
filterOrIn | filterOrIn(field, values, combine?) | Build an OData filter from a list of values โ compact [field, 'in', [...]], or a chained (field = a) or (field = b) form. Returns null when there are no values. |
dxFilterToString | dxFilterToString({ filter, encode? }) | Convert a DevExtreme filter object to an OData v4 $filter string. Handles and/or, comparisons (eq/ne/gtโฆ), and contains/startswith/endswith. Optional URL encoding. |
Numeric input helper โ
| Helper | Signature | Description |
|---|---|---|
preventMinus | preventMinus() | Block the minus sign on numeric fields โ ASCII - and Unicode โ, via keydown and paste. Returns { onKeyDown, onPaste }. |
JSON & misc utilities โ
| Helper | Signature | Description |
|---|---|---|
isDate | isDate(value): value is Date | Type guard โ true for a valid Date or a parseable date string/number. |
isJSONString | isJSONString({ input, strict?, root? }) | Check whether a string is valid JSON. Optional strict/lenient mode and a root filter (array / object / primitive). |
safeJSONParse | safeJSONParse(str): any | Parse JSON with fallbacks for double-wrapped strings and error arrays like [System.Exception: {...}]. Returns null on failure. |
Notification renderer (MonoNotivue) โ
notif pushes toasts through notivue; MonoNotivue is the drop-in renderer for your app shell. It replaces the hand-wired <Notivue v-slot>โฆ</Notivue> block โ action notifications render a custom card with buttons, everything else uses notivue's default toast with the pastel theme.
vue
<script setup lang="ts">
import { MonoNotivue } from 'mono-utils/runtime'
</script>
<template>
<main>
<MonoNotivue />
<RouterView />
</main>
</template>The notivue plugin (createNotivue(...) + app.use(...)) and its CSS (notivue/notifications.css, notivue/animations.css) are still registered once in the app's main.ts. See the Notivue addon for the full setup, the per-template differences (Host / Remote / Nuxt), and the monoFetch integration.
Fetching lives elsewhere
mono-utils also has fetching / datasource-building helpers, but those go through mono-utils/fetching โ see Data Fetching and DataSource. This page only covers the value-add helpers above; see Template Rules (Rule 13) for the when-to-use-them rule.