@regle/mcp-server 1.26.1 → 1.27.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/regle-mcp-server.js +5 -5
- package/package.json +5 -5
package/dist/regle-mcp-server.js
CHANGED
|
@@ -89,14 +89,14 @@ const rawData = {
|
|
|
89
89
|
"title": "Server errors",
|
|
90
90
|
"category": "common-usage",
|
|
91
91
|
"path": "common-usage/external-errors.md",
|
|
92
|
-
"content": "# External errors\n\nRegle handles only client side errors. But some validation may need to be submitted to a server and returned to the client.\n\nTo handle this, you can use the `externalErrors` modifier.\n\nIt matches the structure of your form, but you can also use dot path to define the errors.\n\n## Basic usage\n\n```ts\nimport { type RegleExternalErrorTree, useRegle } from '@regle/core'\n\nconst form = reactive({\n email: '',\n name: {\n pseudo: '',\n },\n})\n\nconst externalErrors = ref<RegleExternalErrorTree<typeof form>>({});\n\nconst { r$ } = useRegle(\n form,\n {\n email: { required },\n name: { pseudo: { required } },\n },\n {\n externalErrors,\n }\n);\n\nasync function submit() {\n const {valid} = await r$.$validate();\n\n if (valid) {\n r$.$setExternalErrors({\n email: [\"Email already exists\"],\n name: {\n pseudo: [\"Pseudo already exists\"]\n },\n })\n }\n}\n```\n\nResult:\n\n:::warning\n\nIf you're working with collections and server-only validations, you'll have to at least specify an empty `$each` object in the client rules to tell Regle that the array is to be treated as a collection\n\n```ts\nconst { r$ } = useRegle({collection: []}, {\n collection: {\n $each: {}\n },\n}, { externalErrors })\n\n```\n\n:::\n\n## Dot path errors\n\n`externalErrors` can also be used to handle dot path errors. \n\nIt can be handy for some backend frameworks that return errors with dot path.\n\n```ts\nimport { useRegle } from '@regle/core';\n\nconst form = reactive({\n email: '',\n name: {\n pseudo: '',\n },\n collection: [{name: ''}]\n})\n\nconst externalErrors = ref<Record<string, string[]>>({});\n\nconst { r$ } = useRegle(form, {}, { externalErrors })\n\nasync function submit() {\n const {valid} = await r$.$validate();\n\n if (valid) {\n r$.$setExternalErrors({\n email: [\"Email already exists\"],\n \"name.pseudo\": [\"Pseudo already exists\"],\n \"collection.0.name\": [\"Name already exists\"]\n })\n }\n}\n``` \n\n## Without the `externalErrors` option\n\n`r$.$setExternalErrors` also works when you don't provide the `externalErrors` option.\nRegle stores those errors internally.\n\n```ts\nconst form = reactive({\n email: '',\n name: {\n pseudo: '',\n },\n})\n\nconst { r$ } = useRegle(form, {\n email: { required },\n name: { pseudo: { required } },\n})\n\nasync function submit() {\n const { valid } = await r$.$validate();\n\n if (!valid) return;\n\n r$.$setExternalErrors({\n email: ['Email already exists'],\n 'name.pseudo': ['Pseudo already exists'],\n });\n}\n```\n\n## Clearing errors\n\nBy default, when you set the external errors, Regle will keep them until the form is validated or modified again.\n\nThis behavior can be modified with these options:\n\n### `clearExternalErrors`\n\n```ts\nr$.$reset({ clearExternalErrors: false });\n```\n\n### `clearExternalErrorsOnValidate`\n\n```ts\nimport { useRegle } from '@regle/core';\n\nconst { r$ } = useRegle(form, {}, { \n externalErrors, \n clearExternalErrorsOnValidate: true \n})\n```\n\n### `clearExternalErrorsOnChange`\n\n```ts\nimport { useRegle } from '@regle/core';\n\nconst { r$ } = useRegle(form, {}, { \n externalErrors, \n clearExternalErrorsOnChange: false \n})\n```\n\n### `$clearExternalErrors()`\n\nYou can also clear the errors manually by calling the `$clearExternalErrors` method.\n\n```ts\nr$.$clearExternalErrors();\n```"
|
|
92
|
+
"content": "# External errors and issues\n\nRegle handles only client side errors. But some validation may need to be submitted to a server and returned to the client.\n\nTo handle this, you can use the `externalErrors` modifier, or `externalIssues` when the server returns structured metadata.\n\nIt matches the structure of your form, but you can also use dot path to define the errors.\n\n## Basic usage\n\n```ts\nimport { type RegleExternalErrorTree, useRegle } from '@regle/core'\n\nconst form = reactive({\n email: '',\n name: {\n pseudo: '',\n },\n})\n\nconst externalErrors = ref<RegleExternalErrorTree<typeof form>>({});\n\nconst { r$ } = useRegle(\n form,\n {\n email: { required },\n name: { pseudo: { required } },\n },\n {\n externalErrors,\n }\n);\n\nasync function submit() {\n const {valid} = await r$.$validate();\n\n if (valid) {\n r$.$setExternalErrors({\n email: [\"Email already exists\"],\n name: {\n pseudo: [\"Pseudo already exists\"]\n },\n })\n }\n}\n```\n\nUse `externalIssues` when you need to keep metadata on each server issue. Its `$message` is still reflected in `$errors`, while the full object is available from `$issues`.\n\n```ts\nimport { type RegleExternalIssueTree, useRegle } from '@regle/core'\n\nconst externalIssues = ref<RegleExternalIssueTree<typeof form>>({});\n\nconst { r$ } = useRegle(form, rules, { externalIssues });\n\nr$.$setExternalIssues({\n email: [\n {\n $message: 'Email already exists',\n $property: 'email',\n code: 'EMAIL_TAKEN',\n },\n ],\n});\n```\n\n### Typing issue metadata\n\nServer payloads often include extra fields (`code`, `field`, i18n keys, and so on). Regle exposes them on `$issues` while still using `$message` for `$errors`.\n\nAugment `RegleIssueCustomMetadata` once (for example in `regle.d.ts` next to your app entry). Keys you add are merged into `RegleFieldIssue` and typed on field `$issues`, including issues coming from `externalIssues`.\n\n`RegleExternalFieldIssue` only requires `$message`. Built-in fields such as `$property` and your custom metadata stay optional when you build the object passed to `externalIssues` or `$setExternalIssues`.\n\n```ts [regle.d.ts]\ndeclare module '@regle/core' {\n interface RegleIssueCustomMetadata {\n code?: string;\n }\n}\n```\n\n```ts\nconst externalIssues = ref<RegleExternalIssueTree<typeof form>>({\n email: [{ $message: 'Email already exists', code: 'EMAIL_TAKEN' }],\n});\n\n// After Regle applies the issue:\nr$.email.$issues[0].code; // string | undefined\nr$.email.$errors[0]; // 'Email already exists'\n```\n\n`externalErrors` and `externalIssues` are mutually exclusive. Setting one clears the other, so the latest server payload is the source of truth.\n\nResult:\n\n:::warning\n\nIf you're working with collections and server-only validations, you'll have to at least specify an empty `$each` object in the client rules to tell Regle that the array is to be treated as a collection\n\n```ts\nconst { r$ } = useRegle({collection: []}, {\n collection: {\n $each: {}\n },\n}, { externalErrors })\n\n```\n\n:::\n\n## Dot path errors\n\n`externalErrors` and `externalIssues` can also be used to handle dot path errors. \n\nIt can be handy for some backend frameworks that return errors with dot path.\n\n```ts\nimport { useRegle } from '@regle/core';\n\nconst form = reactive({\n email: '',\n name: {\n pseudo: '',\n },\n collection: [{name: ''}]\n})\n\nconst externalErrors = ref<Record<string, string[]>>({});\n\nconst { r$ } = useRegle(form, {}, { externalErrors })\n\nasync function submit() {\n const {valid} = await r$.$validate();\n\n if (valid) {\n r$.$setExternalErrors({\n email: [\"Email already exists\"],\n \"name.pseudo\": [\"Pseudo already exists\"],\n \"collection.0.name\": [\"Name already exists\"]\n })\n }\n}\n``` \n\n## Without the `externalErrors` option\n\n`r$.$setExternalErrors` also works when you don't provide the `externalErrors` option.\nRegle stores those errors internally.\n\n```ts\nconst form = reactive({\n email: '',\n name: {\n pseudo: '',\n },\n})\n\nconst { r$ } = useRegle(form, {\n email: { required },\n name: { pseudo: { required } },\n})\n\nasync function submit() {\n const { valid } = await r$.$validate();\n\n if (!valid) return;\n\n r$.$setExternalErrors({\n email: ['Email already exists'],\n 'name.pseudo': ['Pseudo already exists'],\n });\n}\n```\n\n## Clearing errors\n\nBy default, when you set the external errors, Regle will keep them until the form is validated or modified again.\n\nThis behavior can be modified with these options:\n\n### `clearExternalErrors`\n\n```ts\nr$.$reset({ clearExternalErrors: false });\n```\n\n### `clearExternalErrorsOnValidate`\n\n```ts\nimport { useRegle } from '@regle/core';\n\nconst { r$ } = useRegle(form, {}, { \n externalErrors, \n clearExternalErrorsOnValidate: true \n})\n```\n\n### `clearExternalErrorsOnChange`\n\n```ts\nimport { useRegle } from '@regle/core';\n\nconst { r$ } = useRegle(form, {}, { \n externalErrors, \n clearExternalErrorsOnChange: false \n})\n```\n\n### `$clearExternalErrors()`\n\nYou can also clear the errors manually by calling the `$clearExternalErrors` method.\n\n```ts\nr$.$clearExternalErrors();\n```\n\nFor structured issues, use the matching methods and options:\n\n```ts\nr$.$setExternalIssues({\n email: [{ $message: 'Email already exists', code: 'EMAIL_TAKEN' }],\n});\n\nr$.$clearExternalIssues();\n\nr$.$reset({ clearExternalErrors: true });\n```\n\n`clearExternalErrorsOnValidate`, `clearExternalErrorsOnChange`, and `clearExternalErrors` also apply to structured external issues."
|
|
93
93
|
},
|
|
94
94
|
{
|
|
95
95
|
"id": "common-usage-reset-form",
|
|
96
96
|
"title": "Reset forms",
|
|
97
97
|
"category": "common-usage",
|
|
98
98
|
"path": "common-usage/reset-form.md",
|
|
99
|
-
"content": "# Reset forms\n\nRegle offers multiple options to reset a form. It depends on your use case and what you want to achieve.\n\nIt can be either:\n- Only resetting the validation state ($dirty, $invalid, $pending etc..)\n- Only resetting the form state ($value) and keeping the validation state\n- Resetting the form state to a given state and keeping the validation state\n- Resetting the form state to a given state and clearing the validation state\n- Reset both form state and validation state to a pristine state\n\n## Basic usage, with `$reset` method\n\nThe `$reset` method is available on every nested instance of field of a form. So you can reset fields individually or the whole form.\n\n### Options\n\nThe `$reset` method accepts an options object with the following properties:\n\n#### `toInitialState`\n- **Type:** `boolean`\n- **Description:** \n Reset validation status and reset form state to its initial state. \n Initial state is different from the original state, as it can be mutated when using `$reset`. This serves as the base comparison for `$edited`. \n ⚠️ This doesn't work if the state is a `reactive` object.\n\n#### `toOriginalState`\n- **Type:** `boolean`\n- **Description:** \n Reset validation status and reset form state to its original state. \n Original state is the unmutated state that was passed to the form when it was initialized.\n\n#### `toState`\n- **Type:** `TState` or `() => TState`\n- **Description:** \n Reset validation status and reset form state to the given state. Also sets the new state as the new initial state.\n\n#### `clearExternalErrors`\n- **Type:** `boolean`\n- **Description:** \n Clears the `$externalErrors` state back to an empty object.\n\n```ts\nr$.$reset(); // Only reset validation state, set the initialValue as the current value\n```\n\n```ts\nr$.$reset({ toInitialState: true }); // Reset validation state and form state to initial state\n```\n\n```ts\nr$.$reset({ toOriginalState: true }); // Reset validation state and form state to original state\n```\n\n```ts\nr$.$reset({ toState: { email: 'test@test.com' } }); // Reset validation state and form state to the given state\n```\n\n```ts\nr$.$reset({ clearExternalErrors: true }); // Clear $externalErrors state\n```\n\n## Example\n\n```vue\n<template>\n <input\n v-model=\"r$.$value.email\"\n :class=\"{ valid: r$.email.$correct, error: r$.email.$error }\"\n placeholder=\"Type your email\"\n />\n <ul v-if=\"r$.$errors.email.length\">\n <li v-for=\"error of r$.$errors.email\" :key=\"error\">\n {{ error }}\n </li>\n </ul>\n <div>\n <button type=\"button\" @click=\"r$.$reset()\">Reset validation state</button>\n <button type=\"button\" @click=\"r$.$reset({ toInitialState: true })\">Reset to initial state</button>\n <button type=\"button\" @click=\"r$.$reset({ toOriginalState: true })\">Reset to original state</button>\n <button type=\"button\" @click=\"r$.$reset({ toState: { email: 'test@test.com' } })\"\n >Reset to a given state</button\n >\n <button class=\"primary\" type=\"button\" @click=\"r$.$validate()\">Submit</button>\n </div>\n</template>\n\n```\n\nResult:"
|
|
99
|
+
"content": "# Reset forms\n\nRegle offers multiple options to reset a form. It depends on your use case and what you want to achieve.\n\nIt can be either:\n- Only resetting the validation state ($dirty, $invalid, $pending etc..)\n- Only resetting the form state ($value) and keeping the validation state\n- Resetting the form state to a given state and keeping the validation state\n- Resetting the form state to a given state and clearing the validation state\n- Reset both form state and validation state to a pristine state\n\n## Basic usage, with `$reset` method\n\nThe `$reset` method is available on every nested instance of field of a form. So you can reset fields individually or the whole form.\n\n### Options\n\nThe `$reset` method accepts an options object with the following properties:\n\n#### `toInitialState`\n- **Type:** `boolean`\n- **Description:** \n Reset validation status and reset form state to its initial state. \n Initial state is different from the original state, as it can be mutated when using `$reset`. This serves as the base comparison for `$edited`. \n ⚠️ This doesn't work if the state is a `reactive` object.\n\n#### `toOriginalState`\n- **Type:** `boolean`\n- **Description:** \n Reset validation status and reset form state to its original state. \n Original state is the unmutated state that was passed to the form when it was initialized.\n\n#### `toState`\n- **Type:** `TState` or `() => TState`\n- **Description:** \n Reset validation status and reset form state to the given state. Also sets the new state as the new initial state.\n\n#### `clearExternalErrors`\n- **Type:** `boolean`\n- **Description:** \n Clears the `$externalErrors` and `$externalIssues` state back to an empty object.\n\n```ts\nr$.$reset(); // Only reset validation state, set the initialValue as the current value\n```\n\n```ts\nr$.$reset({ toInitialState: true }); // Reset validation state and form state to initial state\n```\n\n```ts\nr$.$reset({ toOriginalState: true }); // Reset validation state and form state to original state\n```\n\n```ts\nr$.$reset({ toState: { email: 'test@test.com' } }); // Reset validation state and form state to the given state\n```\n\n```ts\nr$.$reset({ clearExternalErrors: true }); // Clear $externalErrors and $externalIssues state\n```\n\n## Example\n\n```vue\n<template>\n <input\n v-model=\"r$.$value.email\"\n :class=\"{ valid: r$.email.$correct, error: r$.email.$error }\"\n placeholder=\"Type your email\"\n />\n <ul v-if=\"r$.$errors.email.length\">\n <li v-for=\"error of r$.$errors.email\" :key=\"error\">\n {{ error }}\n </li>\n </ul>\n <div>\n <button type=\"button\" @click=\"r$.$reset()\">Reset validation state</button>\n <button type=\"button\" @click=\"r$.$reset({ toInitialState: true })\">Reset to initial state</button>\n <button type=\"button\" @click=\"r$.$reset({ toOriginalState: true })\">Reset to original state</button>\n <button type=\"button\" @click=\"r$.$reset({ toState: { email: 'test@test.com' } })\"\n >Reset to a given state</button\n >\n <button class=\"primary\" type=\"button\" @click=\"r$.$validate()\">Submit</button>\n </div>\n</template>\n\n```\n\nResult:"
|
|
100
100
|
},
|
|
101
101
|
{
|
|
102
102
|
"id": "common-usage-standard-schema",
|
|
@@ -131,7 +131,7 @@ const rawData = {
|
|
|
131
131
|
"title": "Modifiers",
|
|
132
132
|
"category": "core-concepts",
|
|
133
133
|
"path": "core-concepts/modifiers.md",
|
|
134
|
-
"content": "# Modifiers\n\nModifiers allow you to control the behavior and settings of validation rules in your application. They can be applied globally to all fields or customized per field.\n\n## Deep modifiers\n\nDeep modifiers are specified as the third argument of the `useRegle` composable. They apply recursively to all fields within your state.\n\n```ts\nconst { r$ } = useRegle({}, {}, {\n /* modifiers */\n})\n```\n\n### `autoDirty`\n\n__Type__: `boolean`\n\n__Default__: `true`\n\nAutomatically set the dirty state to `true` when the value changes.\n\n### `immediateDirty`\n\n__Type__: `boolean | 'eager' | 'non-empty' | 'lazy-non-empty'`\n\n__Default__: `false`\n\nSet the dirty state to `true` when the form is initialized.\n\n- `true` or `'eager'`: touch the whole form on mount.\n- `'non-empty'`: touch the whole form on mount only if one of the initial values is non-empty.\n- `'lazy-non-empty'`: touch only the fields that are non-empty on mount.\n\n### `disabled`\n\n__Type__: `boolean`\n\n__Default__: `false`\n\nTemporarily pauses Regle reactivity and validation computation.\n\nWhen `disabled` is `true`, state changes still happen, but validation status does not update until you enable it again.\n\n```ts\nimport { ref } from 'vue';\nimport { useRegle } from '@regle/core';\nimport { required } from '@regle/rules';\n\nconst disabled = ref(false);\n\nconst { r$ } = useRegle(\n { name: '' },\n { name: { required } },\n { disabled }\n);\n\ndisabled.value = true;\nr$.$value.name = 'John'; // value updates, validation is paused\n\ndisabled.value = false; // validation reactivity resumes\n```\n\n### `silent`\n\n__Type__: `boolean`\n\n__Default__: `false`\n\nRegle Automatically tracks changes in the state for all nested rules. If set to `true`, you must manually call `$touch` or `$validate` to display errors.\n\n### `lazy`\n\n__Type__: `boolean`\n\n__Default__: `false`\n\nUsage:\n\nWhen set to false, tells the rules to be called on init, otherwise they are lazy and only called when the field is dirty.\n\n### `externalErrors`\n\n__Type__: `RegleExternalErrorTree<State>` \n\nPass an object, matching your error state, that holds external validation errors. These can be from a backend validations or something else.\n\nCheck the [External errors](/common-usage/external-errors) section for more details.\n\n### `rewardEarly`\n\n__Type__: `boolean`\n\n__Default__: `false`\n\n__Side effect__: disable `$autoDirty` when `true`.\n\nEnables the `reward-early-punish-late` mode of Regle. This mode will not set fields as invalid once they are valid, unless manually triggered by `$validate` method.\n\nThis has no effect when `autoDirty` is set to `true` (the default). Set `autoDirty: false` for `rewardEarly` to take effect.\n\n### `clearExternalErrorsOnChange`\n\n__Type__: `boolean`\n\n__Default__: `true`\n\nThis mode is similar to `rewardEarly`, but only applies to external errors.\nSetting it to `false` will keep the server errors until `$clearExternalErrors` is called.\n\n### `clearExternalErrorsOnValidate`\n\n__Type__: `boolean`\n\n__Default__: `false`\n\nThis mode is similar to `clearExternalErrorsOnChange`, but for the `$validate` and `$validateSync` methods.\nSetting it to `false` will keep the server errors until `$clearExternalErrors` is called manually, or
|
|
134
|
+
"content": "# Modifiers\n\nModifiers allow you to control the behavior and settings of validation rules in your application. They can be applied globally to all fields or customized per field.\n\n## Deep modifiers\n\nDeep modifiers are specified as the third argument of the `useRegle` composable. They apply recursively to all fields within your state.\n\n```ts\nconst { r$ } = useRegle({}, {}, {\n /* modifiers */\n})\n```\n\n### `autoDirty`\n\n__Type__: `boolean`\n\n__Default__: `true`\n\nAutomatically set the dirty state to `true` when the value changes.\n\n### `immediateDirty`\n\n__Type__: `boolean | 'eager' | 'non-empty' | 'lazy-non-empty'`\n\n__Default__: `false`\n\nSet the dirty state to `true` when the form is initialized.\n\n- `true` or `'eager'`: touch the whole form on mount.\n- `'non-empty'`: touch the whole form on mount only if one of the initial values is non-empty.\n- `'lazy-non-empty'`: touch only the fields that are non-empty on mount.\n\n### `disabled`\n\n__Type__: `boolean`\n\n__Default__: `false`\n\nTemporarily pauses Regle reactivity and validation computation.\n\nWhen `disabled` is `true`, state changes still happen, but validation status does not update until you enable it again.\n\n```ts\nimport { ref } from 'vue';\nimport { useRegle } from '@regle/core';\nimport { required } from '@regle/rules';\n\nconst disabled = ref(false);\n\nconst { r$ } = useRegle(\n { name: '' },\n { name: { required } },\n { disabled }\n);\n\ndisabled.value = true;\nr$.$value.name = 'John'; // value updates, validation is paused\n\ndisabled.value = false; // validation reactivity resumes\n```\n\n### `silent`\n\n__Type__: `boolean`\n\n__Default__: `false`\n\nRegle Automatically tracks changes in the state for all nested rules. If set to `true`, you must manually call `$touch` or `$validate` to display errors.\n\n### `lazy`\n\n__Type__: `boolean`\n\n__Default__: `false`\n\nUsage:\n\nWhen set to false, tells the rules to be called on init, otherwise they are lazy and only called when the field is dirty.\n\n### `externalErrors`\n\n__Type__: `RegleExternalErrorTree<State>` \n\nPass an object, matching your error state, that holds external validation errors. These can be from a backend validations or something else.\n\nCheck the [External errors](/common-usage/external-errors) section for more details.\n\n### `externalIssues`\n\n__Type__: `RegleExternalIssueTree<State>`\n\nPass an object, matching your state, that holds structured external validation issues. Each issue keeps its metadata in `$issues`, and its `$message` is also exposed through `$errors`.\n\n`externalIssues` and `externalErrors` are mutually exclusive. Setting one clears the other.\n\nCheck the [External errors and issues](/common-usage/external-errors) section for more details.\n\n### `rewardEarly`\n\n__Type__: `boolean`\n\n__Default__: `false`\n\n__Side effect__: disable `$autoDirty` when `true`.\n\nEnables the `reward-early-punish-late` mode of Regle. This mode will not set fields as invalid once they are valid, unless manually triggered by `$validate` method.\n\nThis has no effect when `autoDirty` is set to `true` (the default). Set `autoDirty: false` for `rewardEarly` to take effect.\n\n### `clearExternalErrorsOnChange`\n\n__Type__: `boolean`\n\n__Default__: `true`\n\nThis mode is similar to `rewardEarly`, but only applies to external errors.\nSetting it to `false` will keep the server errors and issues until `$clearExternalErrors` or `$clearExternalIssues` is called.\n\n### `clearExternalErrorsOnValidate`\n\n__Type__: `boolean`\n\n__Default__: `false`\n\nThis mode is similar to `clearExternalErrorsOnChange`, but for the `$validate` and `$validateSync` methods.\nSetting it to `false` will keep the server errors and issues until `$clearExternalErrors` or `$clearExternalIssues` is called manually, or `externalErrors` / `externalIssues` is set again.\n\n### `validationGroups`\n\n__Type__: `(fields) => Record<string, (RegleFieldStatus |RegleCollectionStatus)[]>`\n\nValidation groups let you merge field properties under one, to better handle validation status.\n\nYou will have access to your declared groups in the `r$.$groups` object.\n\n```ts twoslash\n\nimport { ref } from 'vue';\n// ---cut---\nimport { useRegle } from '@regle/core';\nimport { required } from '@regle/rules';\n\nconst { r$ } = useRegle({ email: '', user: { firstName: '' } }, {\n email: { required },\n user: {\n firstName: { required },\n }\n}, {\n validationGroups: (fields) => ({\n group1: [fields.email, fields.user.firstName]\n })\n})\n\nr$.$groups.group1.\n\n```\n<br><br><br><br>\n\n## Per-field modifiers\n\nPer-field modifiers allow to customize more precisely which behavior you want for each field.\n\n```ts twoslash\n\nimport { useRegle } from '@regle/core';\n// ---cut---\nconst { r$ } = useRegle({ name: '' }, {\n name: { $ }\n\n})\n```\n\n<br><br>\n\n`$autoDirty` `$lazy`, `$silent`, `$immediateDirty` and `$rewardEarly` work the same as the deep modifiers.\n\n### `$debounce`\nType: `number` (ms)\n\nThis let you declare the number of milliseconds the rule needs to wait before executing. Useful for async or heavy computations.\n\n:::tip\nAll async rules have a default debounce of `200ms`, you can disable or modify this setting with `$debounce`\n:::\n\n### `$isEdited`\nType: `(currentValue: MaybeInput<TValue>, initialValue: MaybeInput<TValue>, defaultHandlerFn: (currentValue: unknown, initialValue: unknown) => boolean) => boolean`\n\nOverride the default `$edited` property handler. Useful to handle custom comparisons for complex object types.\n\n:::warning\nIt's highly recommended to use this modifier with the [`markStatic`](/advanced-usage/immutable-constructors) helper to handle immutable constructors.\n:::\n\n```ts\nimport { markStatic, useRegle } from '@regle/core';\nimport { Decimal } from 'decimal.js';\nimport { required } from '@regle/rules';\n\nconst { r$ } = useRegle({ decimal: markStatic(new Decimal(1)) }, {\n decimal: {\n required,\n $isEdited(currentValue, initialValue, defaultHandlerFn) {\n if (currentValue != null && initialValue != null) {\n return currentValue.toNearest(0.01).toString() !== initialValue.toNearest(0.01).toString();\n }\n // fallback to the default handler\n return defaultHandlerFn(currentValue, initialValue);\n },\n },\n})\n```\n\n## Array specific modifiers\n\nThis modifiers are only impacting Array collections.\n\n```ts\nconst { r$ } = useRegle({ collection: [] }, {\n collection: { /** Deep modifiers */ }\n})\n```\n\n### `$deepCompare`\nType: `boolean`\n\nDefault: `false`\n\nAllow deep compare of array children to compute the `$edited` property.\n\nIt's disabled by default for performance reasons."
|
|
135
135
|
},
|
|
136
136
|
{
|
|
137
137
|
"id": "core-concepts-rules-built-in-rules",
|
|
@@ -187,7 +187,7 @@ const rawData = {
|
|
|
187
187
|
"title": "Validation properties",
|
|
188
188
|
"category": "core-concepts",
|
|
189
189
|
"path": "core-concepts/validation-properties.md",
|
|
190
|
-
"content": "# Validation properties\n\nValidation properties are computed values or methods available for every nested rule status, including `r$` and `regle`.\n\nLet's take a look at a simple example to explain the different properties.\n\n``` vue twoslash\n\n```\n<br/>\n\n## Computed properties for fields\n\n### `$invalid` \n- Type: `readonly boolean`\n\nIndicates whether the field is invalid. It becomes `true` if any associated rules return `false`.\n\n### `$correct` \n- Type: `readonly boolean`\n \nThis is not the opposite of `$invalid`. Correct is meant to display UI validation report. \nThis will be `true` only if:\n- The field have at least one active rule\n- Is dirty and not empty\n- Passes validation\n\n### `$dirty` \n- Type: `readonly boolean`\n \nIndicates whether a field has been validated or interacted with by the user at least once. It's typically used to determine if a message should be displayed to the user. You can change this flag manually using the `$touch` and `$reset` methods. The `$dirty` flag is considered true if the current model has been touched or if all its children are dirty. \n\n### `$anyDirty` \n- Type: `readonly boolean`\n\nSimilar to `$dirty`, with one exception. The `$anyDirty` flag is considered true if given model was touched or any of its children are `$anyDirty` which means at least one descendant is `$dirty`.\n\n### `$edited` \n- Type: `readonly boolean`\n \nIndicates whether a field has been touched and if the value is different than the initial one.\n\n### `$anyEdited` \n- Type: `readonly boolean`\n\nSimilar to `$edited`, with one exception. The $anyEdited flag is considered true if given model was edited or any of its children are $anyEdited which means at least one descendant is `$edited`.\n\n### `$value` \n- Type: `TValue` (The current property value type)\n\nA reference to the original validated model. It can be used to bind your form with `v-model`.\n\n### `$silentValue` \n- Type: `TValue` (The current property value type)\n\n`$value` variant that will not \"touch\" the field and update the value silently, running only the rules, so you can easily swap values without impacting user interaction.\n\n### `$initialValue` \n- Type: `TValue` \n\nInitial value of the field. This value will be set to the current `$value` when using `$reset`.\n\n### `$originalValue` \n- Type: `TValue` \n\nOriginal value of the field. This value is the unmutated state that was passed to the form when it was initialized. This value will not be mutated when using `$reset`.\n\n \n### `$pending` \n- Type: `readonly boolean`\n\nIndicates if any async rule for the field is currently running. Always `false` for synchronous rules.\n\n### `$ready` \n- Type: `readonly boolean`\n\nIndicates whether the field is ready for submission. Equivalent to `!$invalid && !$pending`.\n\n### `$error` \n- Type: `readonly boolean`\n\nConvenience flag to easily decide if a message should be displayed. Equivalent to `$dirty && !$pending && $invalid`.\n\n### `$errors` \n- Type: `readonly string[]`\n\nCollection of all the error messages, collected for all children properties and nested forms. Only contains errors from properties where $dirty equals `true`.\n\n### `$silentErrors` \n- Type: `readonly string[]`\n\nCollection of all the error messages, collected for all children properties.\n\n### `$issues` \n- Type: `RegleFieldIssue[]`\n\nCollect all metadata of validators (errors, messages etc). Only contains metadata from properties where $dirty equals true.\n\n### `$name` \n- Type: `readonly string`\n\nReturn the current key name of the field.\n\n## Common methods for fields\n\n### `$validate` \n- Type: `(forceValues?: TState) => Promise<false | SafeOutput<TState>>`\n\nSets all properties as dirty, triggering all rules. \nIt returns a promise that will either resolve to `false` or a Headless copy of your form state. Values that had the `required` rule will be transformed into a non-nullable value (type only).\n\n#### `forceValues` parameter\n\nThe first argument is optional and can be used to assign a new state before validating. It's equivalent to use `r$.$value = x` and `r$.$validate();`.\n\n### `$validateSync` \n- Type: `(forceValues?: TState) => boolean`\n\nValidates the form synchronously without waiting for async rules. This method:\n- Does **NOT** wait for async validation results (async rules are skipped and assumed valid)\n- Returns a `boolean` directly instead of a `Promise`\n\nUse this when you need immediate validation feedback without side effects, such as for real-time UI feedback or form gating logic.\n\n```ts\n// Basic usage\nconst isValid = r$.$validateSync();\n\n// Field-level validation\nconst isEmailValid = r$.email.$validateSync();\n\n// Use with form submission gating\nfunction handleSubmit() {\n if (r$.$validateSync()) {\n // Proceed with submission\n }\n}\n```\n\n:::warning\nSince `$validateSync` skips async rules, use `$validate()` when you need to ensure all validations (including async) have passed before submission.\n:::\n\n### `$extractDirtyFields` \n- Type: `(filterNullishValues = true) => DeepPartial<TState>`\n\nWill return a copy of your state with only the fields that are dirty.\nBy default it will filter out nullish values or objects, but you can override it with the first parameter `$extractDirtyFields(false)`.\n\n### `$touch` \n- Type: `() => void`\n\nMarks the field and all nested properties as `$dirty`.\n\n### `$reset` \n- Type: `(options?: ResetOptions) => void`\n\nReset the validation status to a pristine state while keeping the current state.\nThe current state is treated as the new initial state.\n\n:::tip\nFor more information about the `$reset` method, check the [resetting forms section](/common-usage/reset-form)\n:::\n\n### `$clearExternalErrors` \n- Type: `() => void`\n\nClears the `$externalErrors` state back to an empty object.\n\n### `$setExternalErrors`\n- Type: `(errors: RegleExternalErrorTree<TState> | Record<string, string[]>) => void`\n\nSets external errors from either a nested object or dot-path keys.\nThis method is available on the root `r$`, and works with or without passing the `externalErrors` option to `useRegle`.\n\n```ts\nr$.$setExternalErrors({\n email: ['Email already exists'],\n 'user.firstName': ['First name already exists'],\n});\n```\n\n### `$addRules`\n- Type: `(rules: RegleRuleDecl) => void`\n\nAdds runtime rules to the current field status.\nThis is useful when a child component receives a `RegleFieldStatus` and needs to attach its own field-specific validation rules.\n\n:::warning\nThis is convenient for children components to add rules to their parent field status, but you will lose a bit of type safety.\n:::\n\n```ts\nconst { r$ } = useRegle(form, {\n password: {},\n});\n\nr$.password.$addRules({\n required,\n minLength: minLength(8),\n});\n```\n\n### `addRules` (deprecated)\n- Type: `(rules: RegleRuleDecl) => void`\n\n:::warning Deprecated\nUse `$addRules` instead. This alias will be removed in a future version.\n:::\n\n## Specific properties for fields\n\n### `$rules` \n- Type: `Record<string, RegleRuleStatus>`\n\nThis is reactive tree containing all the declared rules of your field.\nTo know more about the rule properties check the [rules properties section](/core-concepts/rules/rules-properties)\n\n \n### `$silentIssues` \n- Type: `RegleFieldIssue[]`\n\nCollect all metadata of validators (errors, messages etc).\n \n\n## Specific properties for nested objects\n\n### `$fields` \n- Type: `Record<string, RegleStatus | RegleFieldStatus | RegleCollectionStatus>`\n\nThis represents all the children of your object. You can access any nested child at any depth to get the relevant data you need for your form.\n\n### `$self`\n- Type: `RegleFieldStatus`\nRepresents the status of the object itself. You can have validation rules on the object like `required`, this field represents the isolated status of the object.\n\n## Specific properties for collections\n\nCheck documentation for [collections here](/common-usage/collections)\n\n### `$each`\n- Type: `Array<string, RegleStatus>`\n\nThis will store the status of every item in your collection. Each item will be a field you can access, or map on it to display your elements.\n\n### `$self` \n- Type: `RegleFieldStatus`\nRepresents the status of the collection itself. You can have validation rules on the array like `minLength`, this field represents the isolated status of the collection."
|
|
190
|
+
"content": "# Validation properties\n\nValidation properties are computed values or methods available for every nested rule status, including `r$` and `regle`.\n\nLet's take a look at a simple example to explain the different properties.\n\n``` vue twoslash\n\n```\n<br/>\n\n## Computed properties for fields\n\n### `$invalid` \n- Type: `readonly boolean`\n\nIndicates whether the field is invalid. It becomes `true` if any associated rules return `false`.\n\n### `$correct` \n- Type: `readonly boolean`\n \nThis is not the opposite of `$invalid`. Correct is meant to display UI validation report. \nThis will be `true` only if:\n- The field have at least one active rule\n- Is dirty and not empty\n- Passes validation\n\n### `$dirty` \n- Type: `readonly boolean`\n \nIndicates whether a field has been validated or interacted with by the user at least once. It's typically used to determine if a message should be displayed to the user. You can change this flag manually using the `$touch` and `$reset` methods. The `$dirty` flag is considered true if the current model has been touched or if all its children are dirty. \n\n### `$anyDirty` \n- Type: `readonly boolean`\n\nSimilar to `$dirty`, with one exception. The `$anyDirty` flag is considered true if given model was touched or any of its children are `$anyDirty` which means at least one descendant is `$dirty`.\n\n### `$edited` \n- Type: `readonly boolean`\n \nIndicates whether a field has been touched and if the value is different than the initial one.\n\n### `$anyEdited` \n- Type: `readonly boolean`\n\nSimilar to `$edited`, with one exception. The $anyEdited flag is considered true if given model was edited or any of its children are $anyEdited which means at least one descendant is `$edited`.\n\n### `$value` \n- Type: `TValue` (The current property value type)\n\nA reference to the original validated model. It can be used to bind your form with `v-model`.\n\n### `$silentValue` \n- Type: `TValue` (The current property value type)\n\n`$value` variant that will not \"touch\" the field and update the value silently, running only the rules, so you can easily swap values without impacting user interaction.\n\n### `$initialValue` \n- Type: `TValue` \n\nInitial value of the field. This value will be set to the current `$value` when using `$reset`.\n\n### `$originalValue` \n- Type: `TValue` \n\nOriginal value of the field. This value is the unmutated state that was passed to the form when it was initialized. This value will not be mutated when using `$reset`.\n\n \n### `$pending` \n- Type: `readonly boolean`\n\nIndicates if any async rule for the field is currently running. Always `false` for synchronous rules.\n\n### `$ready` \n- Type: `readonly boolean`\n\nIndicates whether the field is ready for submission. Equivalent to `!$invalid && !$pending`.\n\n### `$error` \n- Type: `readonly boolean`\n\nConvenience flag to easily decide if a message should be displayed. Equivalent to `$dirty && !$pending && $invalid`.\n\n### `$errors` \n- Type: `readonly string[]`\n\nCollection of all the error messages, collected for all children properties and nested forms. Only contains errors from properties where $dirty equals `true`.\n\n### `$silentErrors` \n- Type: `readonly string[]`\n\nCollection of all the error messages, collected for all children properties.\n\n### `$issues` \n- Type: `RegleFieldIssue[]`\n\nCollect all metadata of validators (errors, messages etc). Only contains metadata from properties where $dirty equals true.\nStructured external issues are also exposed here with their metadata.\n\n### `$name` \n- Type: `readonly string`\n\nReturn the current key name of the field.\n\n## Common methods for fields\n\n### `$validate` \n- Type: `(forceValues?: TState) => Promise<false | SafeOutput<TState>>`\n\nSets all properties as dirty, triggering all rules. \nIt returns a promise that will either resolve to `false` or a Headless copy of your form state. Values that had the `required` rule will be transformed into a non-nullable value (type only).\n\n#### `forceValues` parameter\n\nThe first argument is optional and can be used to assign a new state before validating. It's equivalent to use `r$.$value = x` and `r$.$validate();`.\n\n### `$validateSync` \n- Type: `(forceValues?: TState) => boolean`\n\nValidates the form synchronously without waiting for async rules. This method:\n- Does **NOT** wait for async validation results (async rules are skipped and assumed valid)\n- Returns a `boolean` directly instead of a `Promise`\n\nUse this when you need immediate validation feedback without side effects, such as for real-time UI feedback or form gating logic.\n\n```ts\n// Basic usage\nconst isValid = r$.$validateSync();\n\n// Field-level validation\nconst isEmailValid = r$.email.$validateSync();\n\n// Use with form submission gating\nfunction handleSubmit() {\n if (r$.$validateSync()) {\n // Proceed with submission\n }\n}\n```\n\n:::warning\nSince `$validateSync` skips async rules, use `$validate()` when you need to ensure all validations (including async) have passed before submission.\n:::\n\n### `$extractDirtyFields` \n- Type: `(filterNullishValues = true) => DeepPartial<TState>`\n\nWill return a copy of your state with only the fields that are dirty.\nBy default it will filter out nullish values or objects, but you can override it with the first parameter `$extractDirtyFields(false)`.\n\n### `$touch` \n- Type: `() => void`\n\nMarks the field and all nested properties as `$dirty`.\n\n### `$reset` \n- Type: `(options?: ResetOptions) => void`\n\nReset the validation status to a pristine state while keeping the current state.\nThe current state is treated as the new initial state.\n\n:::tip\nFor more information about the `$reset` method, check the [resetting forms section](/common-usage/reset-form)\n:::\n\n### `$clearExternalErrors` \n- Type: `() => void`\n\nClears the `$externalErrors` state back to an empty object.\n\n### `$setExternalErrors`\n- Type: `(errors: RegleExternalErrorTree<TState> | Record<string, string[]>) => void`\n\nSets external errors from either a nested object or dot-path keys.\nThis method is available on the root `r$`, and works with or without passing the `externalErrors` option to `useRegle`.\n\n```ts\nr$.$setExternalErrors({\n email: ['Email already exists'],\n 'user.firstName': ['First name already exists'],\n});\n```\n\n### `$clearExternalIssues`\n- Type: `() => void`\n\nClears the `$externalIssues` state back to an empty object.\n\n### `$setExternalIssues`\n- Type: `(issues: RegleExternalIssueTree<TState> | Record<string, RegleFieldIssue[]>) => void`\n\nSets structured external issues from either a nested object or dot-path keys.\nThe full issue objects are available in `$issues`, and each `$message` is also exposed in `$errors`.\nThis method is mutually exclusive with `$setExternalErrors`: setting one clears the other.\n\n```ts\nr$.$setExternalIssues({\n email: [\n {\n $message: 'Email already exists',\n code: 'EMAIL_TAKEN',\n },\n ],\n});\n```\n\n### `$addRules`\n- Type: `(rules: RegleRuleDecl) => void`\n\nAdds runtime rules to the current field status.\nThis is useful when a child component receives a `RegleFieldStatus` and needs to attach its own field-specific validation rules.\n\n:::warning\nThis is convenient for children components to add rules to their parent field status, but you will lose a bit of type safety.\n:::\n\n```ts\nconst { r$ } = useRegle(form, {\n password: {},\n});\n\nr$.password.$addRules({\n required,\n minLength: minLength(8),\n});\n```\n\n### `addRules` (deprecated)\n- Type: `(rules: RegleRuleDecl) => void`\n\n:::warning Deprecated\nUse `$addRules` instead. This alias will be removed in a future version.\n:::\n\n## Specific properties for fields\n\n### `$rules` \n- Type: `Record<string, RegleRuleStatus>`\n\nThis is reactive tree containing all the declared rules of your field.\nTo know more about the rule properties check the [rules properties section](/core-concepts/rules/rules-properties)\n\n \n### `$silentIssues` \n- Type: `RegleFieldIssue[]`\n\nCollect all metadata of validators (errors, messages etc).\n \n\n## Specific properties for nested objects\n\n### `$fields` \n- Type: `Record<string, RegleStatus | RegleFieldStatus | RegleCollectionStatus>`\n\nThis represents all the children of your object. You can access any nested child at any depth to get the relevant data you need for your form.\n\n### `$self`\n- Type: `RegleFieldStatus`\nRepresents the status of the object itself. You can have validation rules on the object like `required`, this field represents the isolated status of the object.\n\n## Specific properties for collections\n\nCheck documentation for [collections here](/common-usage/collections)\n\n### `$each`\n- Type: `Array<string, RegleStatus>`\n\nThis will store the status of every item in your collection. Each item will be a field you can access, or map on it to display your elements.\n\n### `$self` \n- Type: `RegleFieldStatus`\nRepresents the status of the collection itself. You can have validation rules on the array like `minLength`, this field represents the isolated status of the collection."
|
|
191
191
|
},
|
|
192
192
|
{
|
|
193
193
|
"id": "examples-advanced",
|
|
@@ -2002,7 +2002,7 @@ function searchApi(query) {
|
|
|
2002
2002
|
});
|
|
2003
2003
|
return results;
|
|
2004
2004
|
}
|
|
2005
|
-
var version = "1.
|
|
2005
|
+
var version = "1.27.0-beta.1";
|
|
2006
2006
|
let posthogClient = null;
|
|
2007
2007
|
posthogClient = new PostHog("phc_kqgJoylCpKkGkkRGxb4MyN2mViehoQcUFEGwVkk4l8E", {
|
|
2008
2008
|
host: "https://eu.i.posthog.com",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@regle/mcp-server",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.27.0-beta.1",
|
|
4
4
|
"description": "MCP Server for Regle",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ai",
|
|
@@ -46,15 +46,15 @@
|
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"@modelcontextprotocol/sdk": "1.29.0",
|
|
49
|
-
"posthog-node": "5.
|
|
49
|
+
"posthog-node": "5.35.13",
|
|
50
50
|
"zod": "4.4.3"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@types/node": "24.12.4",
|
|
54
|
-
"@typescript/native-preview": "7.0.0-dev.
|
|
54
|
+
"@typescript/native-preview": "7.0.0-dev.20260603.1",
|
|
55
55
|
"dotenv": "17.4.2",
|
|
56
|
-
"tsdown": "0.
|
|
57
|
-
"tsx": "4.
|
|
56
|
+
"tsdown": "0.22.1",
|
|
57
|
+
"tsx": "4.22.4",
|
|
58
58
|
"typescript": "6.0.3"
|
|
59
59
|
},
|
|
60
60
|
"scripts": {
|