@regle/mcp-server 1.16.2 → 1.17.0

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.
@@ -20,7 +20,7 @@ var docs_data_default = {
20
20
  "title": "Global configuration",
21
21
  "category": "advanced-usage",
22
22
  "path": "advanced-usage/global-config.md",
23
- "content": "# Global configuration\n\nIf your app includes multiple forms, it can be helpful to define a global configuration that centralizes your custom validators, error messages, and modifiers. This eliminates the need to declare these settings repeatedly for every `useRegle` call, improving both code consistency and developer experience with features like autocompletion and type checking.\n\n## Replace built-in rules messages\n\nEach `@regle/rules` rule provides a default error message. You may may not want to call `withMessage` every time you need to use one with a custom error message.\n\n`defineRegleConfig` allows you to redefine the default messages of built-in rules.\n\n```ts\nimport { defineRegleConfig } from '@regle/core';\nimport { withMessage, minLength, required } from '@regle/rules';\n\nconst { useRegle: useCustomRegle } = defineRegleConfig({\n rules: () => ({\n required: withMessage(required, 'You need to provide a value'),\n minLength: withMessage(minLength, ({ $value, $params: [max] }) => {\n return `Minimum length is ${max}. Current length: ${$value?.length}`;\n })\n })\n})\n\nconst { r$ } = useCustomRegle({ name: '' }, {\n name: {\n required,\n minLength: minLength(6)\n }\n})\n```\n\nResult: \n\n:::tip\nIf you use Nuxt, check out the [Nuxt module](/integrations/nuxt) for a even better DX. \nIt provides a way to add your custom global config to your auto-imports.\n:::\n\n### i18n\n\nYou can also use any i18n library directly inside the config.\n\n```ts\nimport { defineRegleConfig } from '@regle/core';\nimport { withMessage, minLength, required } from '@regle/rules';\nimport { useI18n } from 'vue-i18n';\n\nconst { useRegle: useCustomRegle } = defineRegleConfig({\n rules: () => {\n const { t } = useI18n()\n\n return {\n required: withMessage(required, t('general.required')),\n minLength: withMessage(minLength, ({ $value, $params: [max] }) => {\n return t('general.minLength', {max});\n })\n }\n }\n})\n```\n\n## Declare new rules\n\nWhile `useRegle` allows you to use any rule key, adding custom rules to the global configuration provides autocompletion and type checking. This improves maintainability and consistency across your application.\n\n```ts twoslash\nconst someAsyncCall = async () => await Promise.resolve(true);\n// ---cut---\n\nimport { defineRegleConfig, createRule, Maybe } from '@regle/core';\nimport { withMessage, isFilled } from '@regle/rules';\n\nconst asyncEmail = createRule({\n async validator(value: Maybe<string>) {\n if (!isFilled(value)) {\n return true;\n }\n\n const result = await someAsyncCall();\n return result;\n },\n message: 'Email already exists',\n});\n\nconst { useRegle: useCustomRegle } = defineRegleConfig({\n rules: () => ({\n asyncEmail\n })\n})\n\nconst { r$ } = useCustomRegle({ name: '' }, {\n name: {\n asy\n\n }\n})\n```\n\n## Declare modifiers\n\nYou can include global modifiers in your configuration to automatically apply them wherever you use the `useRegle` composable. This avoids repetitive declarations and keeps your code clean.\n\n```ts\nimport { defineRegleConfig } from '@regle/core';\nimport { withMessage, minLength, required } from '@regle/rules';\n\nexport const { useRegle: useCustomRegle } = defineRegleConfig({\n modifiers: {\n autoDirty: false,\n silent: true,\n lazy: true,\n rewardEarly: true\n }\n})\n```\n\n## Export scoped `inferRules` helper\n\n`defineRegleConfig` also returns a scoped `inferRules` helper, similar to the one exported from `@regle/core`, but that will autocomplete and check your custom rules.\n\nFor information about `inferRules`, check [Typing rules docs](/typescript/typing-rules)\n\n```ts\nimport { defineRegleConfig } from '@regle/core';\nimport { withMessage, minLength, required } from '@regle/rules';\n\nexport const { useRegle, inferRules } = defineRegleConfig({/* */})\n```\n\n## Extend global config\n\nIt's also possible to add additional config to an already created custom `useRegle`.\n\nWith `extendRegleConfig`, you can recreate a custom one with a existing composable as an input.\n\n```ts twoslash\n\nimport { defineRegleConfig, extendRegleConfig, createRule } from '@regle/core';\nimport { withMessage, required } from '@regle/rules';\n\nconst { useRegle: useCustomRegle } = defineRegleConfig({\n rules: () => ({\n customRule: withMessage(required, 'Custom rule'),\n })\n})\n\nconst {useRegle: useExtendedRegle} = extendRegleConfig(useCustomRegle, {\n rules: () => ({\n customRuleExtended: withMessage(required, 'Custom rule 2'),\n })\n})\n\nuseExtendedRegle({name: ''}, {\n name: {\n custom\n \n }\n})\n\n```"
23
+ "content": "# Global configuration\n\nIf your app includes multiple forms, it can be helpful to define a global configuration that centralizes your custom validators, error messages, and modifiers. This eliminates the need to declare these settings repeatedly for every `useRegle` call, improving both code consistency and developer experience with features like autocompletion and type checking.\n\n## Replace built-in rules messages\n\nEach `@regle/rules` rule provides a default error message. You may may not want to call `withMessage` every time you need to use one with a custom error message.\n\n`defineRegleConfig` allows you to redefine the default messages of built-in rules.\n\n```ts\nimport { defineRegleConfig } from '@regle/core';\nimport { withMessage, minLength, required } from '@regle/rules';\n\nconst { useRegle: useCustomRegle } = defineRegleConfig({\n rules: () => ({\n required: withMessage(required, 'You need to provide a value'),\n minLength: withMessage(minLength, ({ $value, $params: [max] }) => {\n return `Minimum length is ${max}. Current length: ${$value?.length}`;\n })\n })\n})\n\nconst { r$ } = useCustomRegle({ name: '' }, {\n name: {\n required,\n minLength: minLength(6)\n }\n})\n```\n\nResult: \n\n:::tip\nIf you use Nuxt, check out the [Nuxt module](/integrations/nuxt) for a even better DX. \nIt provides a way to add your custom global config to your auto-imports.\n:::\n\n### i18n\n\nYou can also use any i18n library directly inside the config.\n\n```ts\nimport { defineRegleConfig } from '@regle/core';\nimport { withMessage, minLength, required } from '@regle/rules';\nimport { useI18n } from 'vue-i18n';\n\nconst { useRegle: useCustomRegle } = defineRegleConfig({\n rules: () => {\n const { t } = useI18n()\n\n return {\n required: withMessage(required, t('general.required')),\n minLength: withMessage(minLength, ({ $value, $params: [max] }) => {\n return t('general.minLength', {max});\n })\n }\n }\n})\n```\n\n## Declare new rules\n\nWhile `useRegle` allows you to use any rule key, adding custom rules to the global configuration provides autocompletion and type checking. This improves maintainability and consistency across your application.\n\n```ts twoslash\nconst someAsyncCall = async () => await Promise.resolve(true);\n// ---cut---\n\nimport { defineRegleConfig, createRule, Maybe } from '@regle/core';\nimport { withMessage, isFilled } from '@regle/rules';\n\nconst asyncEmail = createRule({\n async validator(value: Maybe<string>) {\n if (!isFilled(value)) {\n return true;\n }\n\n const result = await someAsyncCall();\n return result;\n },\n message: 'Email already exists',\n});\n\nconst { useRegle: useCustomRegle } = defineRegleConfig({\n rules: () => ({\n asyncEmail\n })\n})\n\nconst { r$ } = useCustomRegle({ name: '' }, {\n name: {\n asy\n\n }\n})\n```\n\n## Declare modifiers\n\nYou can include global modifiers in your configuration to automatically apply them wherever you use the `useRegle` composable. This avoids repetitive declarations and keeps your code clean.\n\n```ts\nimport { defineRegleConfig } from '@regle/core';\nimport { withMessage, minLength, required } from '@regle/rules';\n\nexport const { useRegle: useCustomRegle } = defineRegleConfig({\n modifiers: {\n autoDirty: false,\n silent: true,\n lazy: true,\n rewardEarly: true\n }\n})\n```\n\n## Export scoped `inferRules` helper\n\n`defineRegleConfig` also returns a scoped `inferRules` helper, similar to the one exported from `@regle/core`, but that will autocomplete and check your custom rules.\n\nFor information about `inferRules`, check [Typing rules docs](/typescript/typing-rules)\n\n```ts\nimport { defineRegleConfig } from '@regle/core';\nimport { withMessage, minLength, required } from '@regle/rules';\n\nexport const { useRegle, inferRules } = defineRegleConfig({/* */})\n```\n\n## Extend global config\n\nIt's also possible to add additional config to an already created custom `useRegle`.\n\nWith `extendRegleConfig`, you can recreate a custom one with a existing composable as an input.\n\n```ts twoslash\n\nimport { defineRegleConfig, extendRegleConfig, createRule } from '@regle/core';\nimport { withMessage, required } from '@regle/rules';\n\nconst { useRegle: useCustomRegle } = defineRegleConfig({\n rules: () => ({\n customRule: withMessage(required, 'Custom rule'),\n })\n})\n\nconst {useRegle: useExtendedRegle} = extendRegleConfig(useCustomRegle, {\n rules: () => ({\n customRuleExtended: withMessage(required, 'Custom rule 2'),\n })\n})\n\nuseExtendedRegle({name: ''}, {\n name: {\n custom\n \n }\n})\n\n```\n\n## Override default behaviors\n\nYou can override the default behaviors of Regle processors by using the `overrides` property.\n\n### `isEdited`\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 override with the [`markStatic`](/advanced-usage/immutable-constructors) helper to handle immutable constructors.\n:::\n\n```ts\nimport { defineRegleConfig } from '@regle/core';\nimport { Decimal } from 'decimal.js';\n\nexport const { useRegle: useCustomRegle } = defineRegleConfig({\n overrides: {\n isEdited(currentValue, initialValue, defaultHandlerFn) {\n if (currentValue instanceof Decimal && initialValue instanceof Decimal) {\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```"
24
24
  },
25
25
  {
26
26
  "id": "advanced-usage-immutable-constructors",
@@ -48,7 +48,7 @@ var docs_data_default = {
48
48
  "title": "Scoped validation",
49
49
  "category": "advanced-usage",
50
50
  "path": "advanced-usage/scoped-validation.md",
51
- "content": "# Scoped validation\n\nScoped validation in Regle is made to port Vuelidate's `nested component validation`.\n\nProblems with Vuelidate's approach:\n - Performances\n - Not declarative\n - Usage (too magic for the user)\n - Type safety\n - Restricted to DOM\n - Have to play with `$scope` and `$stopPropagation` to avoid unwanted behaviour\n\nRegle's solution solves all this problems\n\n## Collecting validation with `useCollectScope` and `useScopedRegle`\n\n### `useScopedRegle`\n\n`useScopedRegle` is a clone of `useRegle`, but with the difference that every time it's used and updated, its state will be collected by the same scope created using `createScopedUseRegle`.\n\nEvery time it's called, a instance will be added for `useCollectScope` to collect.\n\nIt can be called multiple times at any place, not only on components, as it's not restricted by DOM.\n\n### `useCollectScope`\n\nThis composable allow you to retrieve every Regle instances created using the sibling composable `useScopedRegle`.\n\nChildren properties like `$value` and `$errors` will not be objects, and are converted into arrays instead.\n\nYou will also have access to every validation properties like `$error`, `$invalid` etc...\n\n:::code-group\n\n```vue [Parent.vue]\n<template>\n <div>\n <Child1 />\n </div>\n\n <Child2 />\n\n Collected errors: <pre>{{ r$.$errors }}</pre>\n</template>\n\n```\n\n```vue [Child1.vue]\n<template>\n <input v-model=\"r$.$value.firstName\" placeholder=\"Type your firstname\" />\n <ul>\n <li v-for=\"error of r$.$errors.firstName\" :key=\"error\">\n {{ error }}\n </li>\n </ul>\n</template>\n\n```\n\n```vue [Child2.vue]\n<template>\n <input v-model=\"r$.$value.email\" placeholder=\"Type your email\" />\n <ul>\n <li v-for=\"error of r$.$errors.email\" :key=\"error\">\n {{ error }}\n </li>\n </ul>\n</template>\n\n```\n:::\n\nResult:\n\n## Multiple scopes\n\nIf you want to create your own separated scope, you can use `createScopedUseRegle` helper method.\n\nIt's advised to change the name of this composable to avoid conflicts or issues.\n\n```ts [scoped-config.ts]\nimport { createScopedUseRegle } from '@regle/core';\n\nexport const { useScopedRegle, useCollectScope } = createScopedUseRegle();\nexport const { \n useScopedRegle: useContactsRegle, \n useCollectScope: useCollectContacts \n} = createScopedUseRegle();\n```\n\n## Namespaces inside scopes\n\nEach scope can collect a specific namespace. Giving a namespace name will collect only the children with the same namespace name.\n\nThe namespace can be reactive, so it will update every time it changes.\n\nIn this example, only the components using the same scope and namespace will be collected.\n\n:::code-group\n```vue [Parent.vue]\n\n```\n\n```vue [Child1.vue]\n<template>\n <input v-model=\"r$.$value.firstName\" placeholder=\"Type your firstname\" />\n <ul>\n <li v-for=\"error of r$.$errors.firstName\" :key=\"error\">\n {{ error }}\n </li>\n </ul>\n</template>\n\n```\n\n```vue [Child2.vue]\n<template>\n <input v-model=\"r$.$value.email\" placeholder=\"Type your email\" />\n <ul>\n <li v-for=\"error of r$.$errors.email\" :key=\"error\">\n {{ error }}\n </li>\n </ul>\n</template>\n\n```\n\nYou can also collect multiple namespaces at once by passing an array of namespace names to the `useCollectScope` function.\n\n```ts\nconst { r$ } = useCollectScope(['contacts', 'persons']);\n```\n:::\n\n## Inject global config\n\nIf you have a global config already registered, simply pass it as a parameter to your `createScopedUseRegle` function.\n\n```ts twoslash [scoped-config.ts]\nimport { createScopedUseRegle, defineRegleConfig } from '@regle/core';\nimport { required, withMessage } from '@regle/rules';\n\nconst { useRegle } = defineRegleConfig({\n rules: () => ({\n custom: withMessage(required, 'Custom error'),\n }),\n});\n\nexport const { useScopedRegle, useCollectScope } = createScopedUseRegle({customUseRegle: useRegle});\n\nconst {r$} = useScopedRegle({name: ''}, {\n name: {\n cus\n\n }\n})\n\n```\n\n## Custom store for instances\n\nBy default collected instances are stored in a local ref. \n\nYou can provide your own store ref.\n\n```ts\nimport { createScopedUseRegle, type ScopedInstancesRecordLike } from '@regle/core';\n\n// Having a default \nconst myCustomStore = ref<ScopedInstancesRecordLike>({});\n\nconst { useScopedRegle, useCollectScope } = createScopedUseRegle({customStore: myCustomStore});\n```\n\n## Collect instances in a Record\n\nBy default collected instances are stored in a readonly array.\n\nIf you want to store your nested instances in a record it's possible with the `asRecord` option.\n\nThis will **require** every nested `useScopeRegle` to provide a parameter `id`.\n\n:::code-group\n\n```ts [scoped-config.ts]\nimport { createScopedUseRegle } from '@regle/core';\n\nexport const { \n useScopedRegle: useScopedRegleItem, \n useCollectScope: useCollectScopeRecord \n} = createScopedUseRegle({ asRecord: true });\n```\n```vue [Parent.vue]\n\n```\n\n```vue [Child1.vue]\n<template>\n <input v-model=\"r$.$value.firstName\" placeholder=\"Type your firstname\" />\n <ul>\n <li v-for=\"error of r$.$errors.firstName\" :key=\"error\">\n {{ error }}\n </li>\n </ul>\n</template>\n\n```\n\n```vue [Child2.vue]\n<template>\n <input v-model=\"r$.$value.email\" placeholder=\"Type your email\" />\n <ul>\n <li v-for=\"error of r$.$errors.email\" :key=\"error\">\n {{ error }}\n </li>\n </ul>\n</template>\n\n```\n:::\n\n## Manually dispose or register a scope entry\n\n`useScopedRegle` also returns two methods: `dispose` and `register`.\n\nYou can then programmatically handle if your component is collected from inside.\n\n```vue\n\n```\n\n## Manual typing\n\n:::warning\nUse with care, only if you're 100% sure of what return type your collected types will have.\n\nThe order of the collected values can change depending on if they added/deleted.\nThis is here for convenience but not advised.\n:::\n\n```ts twoslash\nimport { useCollectScope } from '@regle/core';\n\nconst { r$ } = useCollectScope<[{ foo: string }]>();\n\nconst { valid, data } = await r$.$validate();\n\n```"
51
+ "content": "# Scoped validation\n\nScoped validation in Regle is made to port Vuelidate's `nested component validation`.\n\nProblems with Vuelidate's approach:\n - Performances\n - Not declarative\n - Usage (too magic for the user)\n - Type safety\n - Restricted to DOM\n - Have to play with `$scope` and `$stopPropagation` to avoid unwanted behaviour\n\nRegle's solution solves all this problems\n\n## Collecting validation with `useCollectScope` and `useScopedRegle`\n\n### `useScopedRegle`\n\n`useScopedRegle` is a clone of `useRegle`, but with the difference that every time it's used and updated, its state will be collected by the same scope created using `createScopedUseRegle`.\n\nEvery time it's called, a instance will be added for `useCollectScope` to collect.\n\nIt can be called multiple times at any place, not only on components, as it's not restricted by DOM.\n\n### `useCollectScope`\n\nThis composable allow you to retrieve every Regle instances created using the sibling composable `useScopedRegle`.\n\nChildren properties like `$value` and `$errors` will not be objects, and are converted into arrays instead.\n\nYou will also have access to every validation properties like `$error`, `$invalid` etc...\n\n:::code-group\n\n```vue [Parent.vue]\n<template>\n <div>\n <Child1 />\n </div>\n\n <Child2 />\n\n Collected errors: <pre>{{ r$.$errors }}</pre>\n</template>\n\n```\n\n```vue [Child1.vue]\n<template>\n <input v-model=\"r$.$value.firstName\" placeholder=\"Type your firstname\" />\n <ul>\n <li v-for=\"error of r$.$errors.firstName\" :key=\"error\">\n {{ error }}\n </li>\n </ul>\n</template>\n\n```\n\n```vue [Child2.vue]\n<template>\n <input v-model=\"r$.$value.email\" placeholder=\"Type your email\" />\n <ul>\n <li v-for=\"error of r$.$errors.email\" :key=\"error\">\n {{ error }}\n </li>\n </ul>\n</template>\n\n```\n:::\n\nResult:\n\n## Multiple scopes\n\nIf you want to create your own separated scope, you can use `createScopedUseRegle` helper method.\n\nIt's advised to change the name of this composable to avoid conflicts or issues.\n\n```ts [scoped-config.ts]\nimport { createScopedUseRegle } from '@regle/core';\n\nexport const { useScopedRegle, useCollectScope } = createScopedUseRegle();\nexport const { \n useScopedRegle: useContactsRegle, \n useCollectScope: useCollectContacts \n} = createScopedUseRegle();\n```\n\n## Namespaces inside scopes\n\nEach scope can collect a specific namespace. Giving a namespace name will collect only the children with the same namespace name.\n\nThe namespace can be reactive, so it will update every time it changes.\n\nIn this example, only the components using the same scope and namespace will be collected.\n\n:::code-group\n```vue [Parent.vue]\n\n```\n\n```vue [Child1.vue]\n<template>\n <input v-model=\"r$.$value.firstName\" placeholder=\"Type your firstname\" />\n <ul>\n <li v-for=\"error of r$.$errors.firstName\" :key=\"error\">\n {{ error }}\n </li>\n </ul>\n</template>\n\n```\n\n```vue [Child2.vue]\n<template>\n <input v-model=\"r$.$value.email\" placeholder=\"Type your email\" />\n <ul>\n <li v-for=\"error of r$.$errors.email\" :key=\"error\">\n {{ error }}\n </li>\n </ul>\n</template>\n\n```\n\nYou can also collect multiple namespaces at once by passing an array of namespace names to the `useCollectScope` function.\n\n```ts\nconst { r$ } = useCollectScope(['contacts', 'persons']);\n```\n:::\n\n## Inject global config\n\nIf you have a global config already registered, simply pass it as a parameter to your `createScopedUseRegle` function.\n\n```ts twoslash [scoped-config.ts]\nimport { createScopedUseRegle, defineRegleConfig } from '@regle/core';\nimport { required, withMessage } from '@regle/rules';\n\nconst { useRegle } = defineRegleConfig({\n rules: () => ({\n custom: withMessage(required, 'Custom error'),\n }),\n});\n\nexport const { useScopedRegle, useCollectScope } = createScopedUseRegle({customUseRegle: useRegle});\n\nconst {r$} = useScopedRegle({name: ''}, {\n name: {\n cus\n\n }\n})\n\n```\n\n## Custom store for instances\n\nBy default collected instances are stored in a local ref. \n\nYou can provide your own store ref.\n\n```ts\nimport { createScopedUseRegle, type ScopedInstancesRecordLike } from '@regle/core';\n\n// Having a default \nconst myCustomStore = ref<ScopedInstancesRecordLike>({});\n\nconst { useScopedRegle, useCollectScope } = createScopedUseRegle({customStore: myCustomStore});\n```\n\n## Collect instances in a Record\n\nBy default collected instances are stored in a readonly array.\n\nIf you want to store your nested instances in a record it's possible with the `asRecord` option.\n\nThis will **require** every nested `useScopeRegle` to provide a parameter `id`.\n\n:::code-group\n\n```ts [scoped-config.ts]\nimport { createScopedUseRegle } from '@regle/core';\n\nexport const { \n useScopedRegle: useScopedRegleItem, \n useCollectScope: useCollectScopeRecord \n} = createScopedUseRegle({ asRecord: true });\n```\n```vue [Parent.vue]\n\n```\n\n```vue [Child1.vue]\n<template>\n <input v-model=\"r$.$value.firstName\" placeholder=\"Type your firstname\" />\n <ul>\n <li v-for=\"error of r$.$errors.firstName\" :key=\"error\">\n {{ error }}\n </li>\n </ul>\n</template>\n\n```\n\n```vue [Child2.vue]\n<template>\n <input v-model=\"r$.$value.email\" placeholder=\"Type your email\" />\n <ul>\n <li v-for=\"error of r$.$errors.email\" :key=\"error\">\n {{ error }}\n </li>\n </ul>\n</template>\n\n```\n:::\n\n## Manually dispose or register a scope entry\n\n`useScopedRegle` also returns two methods: `dispose` and `register`.\n\nYou can then programmatically handle if your component is collected from inside.\n\n```vue\n\n```\n\n## Manual typing\n\n:::warning\nUse with care, only if you're 100% sure of what return type your collected types will have.\n\nThe order of the collected values can change depending on if they added/deleted.\nThis is here for convenience but not advised.\n:::\n\n```ts twoslash\nimport { useCollectScope } from '@regle/core';\n\nconst { r$ } = useCollectScope<[{ foo: string }]>();\n\nconst { valid, data } = await r$.$validate();\n\n```\n\n## Testing\n\nIf you write unit test for a component using scoped validation, you may encounter problems with the tests failing.\n\nTo solve this, mount your component with the `attachTo` option set to the document element.\n\n```ts\nimport { mount } from '@vue/test-utils';\nimport ComponentUsingCollectScope from './ComponentUsingCollectScope.vue';\n\nconst wrapper = mount(ComponentUsingCollectScope, {\n attachTo: document.documentElement,\n});\n```"
52
52
  },
53
53
  {
54
54
  "id": "advanced-usage-variants",
@@ -125,7 +125,7 @@ var docs_data_default = {
125
125
  "title": "Modifiers",
126
126
  "category": "core-concepts",
127
127
  "path": "core-concepts/modifiers.md",
128
- "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 set without the need of `$value` or `$touch`.\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 will have no effect only if you use `autoDirty: true`.\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### `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` 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## 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."
128
+ "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 set without the need of `$value` or `$touch`.\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 will have no effect only if you use `autoDirty: true`.\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### `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` 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."
129
129
  },
130
130
  {
131
131
  "id": "core-concepts-rules-built-in-rules",
@@ -1814,7 +1814,7 @@ function searchApi(query) {
1814
1814
  return results;
1815
1815
  }
1816
1816
 
1817
- var version = "1.16.2";
1817
+ var version = "1.17.0";
1818
1818
 
1819
1819
  let posthogClient = null;
1820
1820
  posthogClient = new PostHog("phc_kqgJoylCpKkGkkRGxb4MyN2mViehoQcUFEGwVkk4l8E", {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@regle/mcp-server",
3
- "version": "1.16.2",
3
+ "version": "1.17.0",
4
4
  "description": "MCP Server for Regle",
5
5
  "dependencies": {
6
6
  "@modelcontextprotocol/sdk": "1.25.2",