@regle/mcp-server 1.18.1 → 1.18.2-beta.2
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 +3 -3
- package/package.json +1 -1
package/dist/regle-mcp-server.js
CHANGED
|
@@ -118,7 +118,7 @@ var docs_data_default = {
|
|
|
118
118
|
"title": "Displaying errors",
|
|
119
119
|
"category": "core-concepts",
|
|
120
120
|
"path": "core-concepts/displaying-errors.md",
|
|
121
|
-
"content": "# Displaying errors\n\nRegle is a headless library, allowing you to display error messages in any way you choose. You can also use its internal state to apply classes or trigger behaviors dynamically.\n\n## Showing errors messages\n\nYou can display your errors by iterating though `r$.xxx.$errors`, `xxx` being the field you need to check.\n\nYou can also access `r$.$errors.xxx` or `r$.$silentErrors.xxx`.\n\nResult:\n\n## Display custom error messages\n\nTo display custom error messages, you can use the [withMessage](/core-concepts/rules/rule-wrappers#withmessage) helper. \nYou have access to additional data like parameters or rule status to write your message.\n\n:::tip\nIf you fall into this case:\n- You have a lot of forms in your app\n- You want to share translations easily between your forms\n\nConsider using [defineRegleConfig](/advanced-usage/global-config#replace-built-in-rules-messages) instead.\n:::\n\n``` vue [App.vue]\n\n```\n\n## i18n and translations\n\nRegle is library agnostic so you can use any i18n library freely, and there is nothing specific to configure, it will just work out of the box.\n\n```vue\n\n```\n\n## Applying an error and valid class\n\nResult:\n\n## Get errors by path\n\nIf you need to access errors for a specific field using a dot-notation path, you can use the `getErrors` utility. This is useful when you need to programmatically access errors or when building reusable input components.\n\n```ts\nimport { getErrors, useRegle } from '@regle/core';\nimport { required, email } from '@regle/rules';\n\nconst { r$ } = useRegle(\n { user: { email: '' }, contacts: [{ name: '' }] },\n {\n user: { email: { required, email } },\n contacts: { $each: { name: { required } } }\n }\n);\n\nawait r$.$validate();\n\n// Access nested errors with dot notation\nconst emailErrors = getErrors(r$, 'user.email');\n// ['This field is required']\n\n// Access collection item errors\nconst contactErrors = getErrors(r$, 'contacts.$each.0.name');\n// ['This field is required']\n```\n\n:::tip\nThe path parameter is **type-safe** - TypeScript will autocomplete available paths and show an error if you try to access a path that doesn't exist or isn't a field with errors.\n:::\n\n## Get issues by path\n\nSimilar to `getErrors`, the `getIssues` utility returns detailed validation issues including metadata like the rule name and custom properties.\n\n```ts\nimport { getIssues, useRegle } from '@regle/core';\nimport { required, minLength } from '@regle/rules';\n\nconst { r$ } = useRegle(\n { user: { name: '' } },\n { user: { name: { required, minLength: minLength(3) } } }\n);\n\nawait r$.$validate();\n\nconst nameIssues = getIssues(r$, 'user.name');\n// [{\n// $message: 'This field is required',\n// $property: 'name',\n// $rule: 'required',\n// $type: 'required'\n// }]\n```\n\n## Display flat errors\n\nIf you want to display the complete list of errors of a form, or the total count of errors, you can use the `flatErrors` utility.\n\nIt will return an array of error strings.\n\n```ts\nimport { flatErrors, useRegle } from '@regle/core';\nimport { email, minLength, required } from '@regle/rules';\n\nconst { r$ } = useRegle(\n { name: '', level0: { email: 'bar' } },\n {\n name: { required, minLength: minLength(5) },\n level0: {\n email: { email },\n },\n }\n);\n\nr$.$validate();\n\nconst flattenErrors = flatErrors(r$.$errors);\n// [\n// \"This field is required\", \n// \"Value must be an valid email address\"\n// ]\n```\n\n### `includePath` option\n\nThis helper also include an option to have the path of the property and returns the issues in Standard Schema Issue format.\n\n```ts\nimport { flatErrors, useRegle } from '@regle/core';\nimport { email, minLength, required } from '@regle/rules';\n\nconst { r$ } = useRegle(\n { name: '', level0: { email: 'bar' } },\n {\n name: { required, minLength: minLength(5) },\n level0: {\n email: { email },\n },\n }\n);\n\nr$.$validate();\n\nconst flattenErrors = flatErrors(r$.$errors, {includePath: true});\n// [\n// { message: \"This field is required\", path: [\"name\"] }, \n// { message: \"Value must be an valid email address\", path: [\"level0\", \"email\"]}\n// ]\n```"
|
|
121
|
+
"content": "# Displaying errors\n\nRegle is a headless library, allowing you to display error messages in any way you choose. You can also use its internal state to apply classes or trigger behaviors dynamically.\n\n## Showing errors messages\n\nYou can display your errors by iterating though `r$.xxx.$errors`, `xxx` being the field you need to check.\n\nYou can also access `r$.$errors.xxx` or `r$.$silentErrors.xxx`.\n\nResult:\n\n## Display custom error messages\n\nTo display custom error messages, you can use the [withMessage](/core-concepts/rules/rule-wrappers#withmessage) helper. \nYou have access to additional data like parameters or rule status to write your message.\n\n:::tip\nIf you fall into this case:\n- You have a lot of forms in your app\n- You want to share translations easily between your forms\n\nConsider using [defineRegleConfig](/advanced-usage/global-config#replace-built-in-rules-messages) instead.\n:::\n\n``` vue [App.vue]\n\n```\n\n## i18n and translations\n\nRegle is library agnostic so you can use any i18n library freely, and there is nothing specific to configure, it will just work out of the box.\n\n```vue\n\n```\n\n## Applying an error and valid class\n\nResult:\n\n## Get errors by path\n\nIf you need to access errors for a specific field using a dot-notation path, you can use the `getErrors` utility. This is useful when you need to programmatically access errors or when building reusable input components.\n\n```ts twoslash\nimport { getErrors, useRegle } from '@regle/core';\nimport { required, email } from '@regle/rules';\n\nconst { r$ } = useRegle(\n { user: { email: '' }, contacts: [{ name: '' }] },\n {\n user: { email: { required, email } },\n contacts: { $each: { name: { required } } }\n }\n);\n\nawait r$.$validate();\n\n// Access nested errors with dot notation\nconst emailErrors = getErrors(r$, 'user.email');\n// ['This field is required']\n\n// Access collection item errors\nconst contactErrors = getErrors(r$, 'contacts.$each.0.name');\n// ['This field is required']\n```\n\n:::tip\nThe path parameter is **type-safe** - TypeScript will autocomplete available paths and show an error if you try to access a path that doesn't exist or isn't a field with errors.\n:::\n\n## Get issues by path\n\nSimilar to `getErrors`, the `getIssues` utility returns detailed validation issues including metadata like the rule name and custom properties.\n\n```ts twoslash\nimport { getIssues, useRegle } from '@regle/core';\nimport { required, minLength } from '@regle/rules';\n\nconst { r$ } = useRegle(\n { user: { name: '' } },\n { user: { name: { required, minLength: minLength(3) } } }\n);\n\nawait r$.$validate();\n\nconst nameIssues = getIssues(r$, 'user.name');\n// [{\n// $message: 'This field is required',\n// $property: 'name',\n// $rule: 'required',\n// $type: 'required'\n// }]\n```\n\n## Display flat errors\n\nIf you want to display the complete list of errors of a form, or the total count of errors, you can use the `flatErrors` utility.\n\nIt will return an array of error strings.\n\n```ts\nimport { flatErrors, useRegle } from '@regle/core';\nimport { email, minLength, required } from '@regle/rules';\n\nconst { r$ } = useRegle(\n { name: '', level0: { email: 'bar' } },\n {\n name: { required, minLength: minLength(5) },\n level0: {\n email: { email },\n },\n }\n);\n\nr$.$validate();\n\nconst flattenErrors = flatErrors(r$.$errors);\n// [\n// \"This field is required\", \n// \"Value must be an valid email address\"\n// ]\n```\n\n### `includePath` option\n\nThis helper also include an option to have the path of the property and returns the issues in Standard Schema Issue format.\n\n```ts\nimport { flatErrors, useRegle } from '@regle/core';\nimport { email, minLength, required } from '@regle/rules';\n\nconst { r$ } = useRegle(\n { name: '', level0: { email: 'bar' } },\n {\n name: { required, minLength: minLength(5) },\n level0: {\n email: { email },\n },\n }\n);\n\nr$.$validate();\n\nconst flattenErrors = flatErrors(r$.$errors, {includePath: true});\n// [\n// { message: \"This field is required\", path: [\"name\"] }, \n// { message: \"Value must be an valid email address\", path: [\"level0\", \"email\"]}\n// ]\n```"
|
|
122
122
|
},
|
|
123
123
|
{
|
|
124
124
|
"id": "core-concepts-index",
|
|
@@ -188,7 +188,7 @@ var docs_data_default = {
|
|
|
188
188
|
"title": "Validation properties",
|
|
189
189
|
"category": "core-concepts",
|
|
190
190
|
"path": "core-concepts/validation-properties.md",
|
|
191
|
-
"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### `$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 [reseting forms section](/common-usage/reset-form)\n:::\n\n### `$clearExternalErrors` \n- Type: `() => void`\n\nClears the $externalResults state back to an empty object.\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## 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
|
+
"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### `$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 [reseting forms section](/common-usage/reset-form)\n:::\n\n### `$clearExternalErrors` \n- Type: `() => void`\n\nClears the $externalResults state back to an empty object.\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."
|
|
192
192
|
},
|
|
193
193
|
{
|
|
194
194
|
"id": "examples-advanced",
|
|
@@ -1934,7 +1934,7 @@ function searchApi(query) {
|
|
|
1934
1934
|
return results;
|
|
1935
1935
|
}
|
|
1936
1936
|
|
|
1937
|
-
var version = "1.18.
|
|
1937
|
+
var version = "1.18.2-beta.2";
|
|
1938
1938
|
|
|
1939
1939
|
let posthogClient = null;
|
|
1940
1940
|
posthogClient = new PostHog("phc_kqgJoylCpKkGkkRGxb4MyN2mViehoQcUFEGwVkk4l8E", {
|