@regle/mcp-server 1.18.2-beta.2 → 1.18.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
|
@@ -69,7 +69,7 @@ var docs_data_default = {
|
|
|
69
69
|
"title": "Cheat Sheet",
|
|
70
70
|
"category": "general",
|
|
71
71
|
"path": "cheat-sheet.md",
|
|
72
|
-
"content": "# Regle Cheat Sheet\n\nQuick reference for common Regle patterns and usage scenarios.\n\n## Basic Setup\n\n```ts\nimport { useRegle } from '@regle/core'\nimport { required, email, minLength } from '@regle/rules'\n\nconst { r$ } = useRegle(\n { name: '', email: '' }, \n { \n name: { required, minLength: minLength(2) },\n email: { required, email }\n }\n)\n```\n\n## Essential Properties\n\n| Property | Description | Example |\n|----------|-------------|---------|\n| `r$.$value` | Form data (reactive) | `r$.$value.email` |\n| `r$.$correct` | Form is dirty and valid | `<button :disabled=\"!r$.$correct\">` |\n| `r$.$invalid` | Form is invalid | `v-if=\"r$.$invalid\"` |\n| `r$.$errors` | All error messages | `r$.$errors.email` |\n| `r$.x.$error` | Field has errors | `v-if=\"r$.email.$error\"` |\n| `r$.x.$correct` | Field is dirty and valid | `v-if=\"r$.email.$correct\"` |\n| `r$.x.$dirty` | Field was touched | `v-if=\"r$.email.$dirty\"` |\n| `r$.$validate()` | Validate form | `await r$.$validate()` |\n| `r$.$reset()` | Reset form | `r$.$reset()` |\n\n## Common Rules\n\n```ts\nimport {useRegle} from '@regle/core';\nimport { \n required, email, minLength, maxLength,\n numeric, between, url, regex,\n alphaNum, alpha, sameAs\n} from '@regle/rules';\n\ntype FormState = {\n name?: string,\n email?: string,\n age?: number,\n username?: string,\n website?: string,\n description?: string,\n phone?: string,\n password?: string,\n confirmPassword?: string,\n}\n\nconst state = ref<FormState>({})\n\nconst { r$ } = useRegle(state, {\n // Basic validation\n name: { required, minLength: minLength(2) },\n email: { required, email },\n age: { required, numeric, between: between(18, 99) },\n \n // String validation\n username: { required, alphaNum, minLength: minLength(3) },\n website: { url },\n description: { maxLength: maxLength(500) },\n \n // Custom patterns\n phone: { regex: regex(/^\\+?[\\d\\s-()]+$/) },\n \n // Password confirmation\n password: { required, minLength: minLength(8) },\n confirmPassword: { \n required, \n sameAs: sameAs(() => state.value.password) \n }\n})\n```\n\n## Field Patterns\n\n### Basic Field with Error Display\n\n```vue\n<template>\n <div>\n <input v-model=\"r$.$value.email\" type=\"email\" />\n <span v-for=\"error of r$.email.$errors\" class=\"error\">\n {{ error }}\n </span>\n </div>\n</template>\n```\n\n### Field with Visual States\n```vue\n<template>\n <input \n v-model=\"r$.$value.email\"\n :class=\"{\n 'error': r$.email.$error,\n 'correct': r$.email.$correct,\n }\"\n />\n</template>\n```\n\n### Optional Field with Conditional Validation\n\n```ts \nimport {inferRules} from '@regle/core';\nimport {requiredIf, minLength, regex} from '@regle/rules';\n\nconst state = ref({phone: ''});\n\nconst rules = computed(() => inferRules(state, {\n phone: {\n // Only required if form have no email\n required: requiredIf(() => !r$.$value.email)\n minLength: minLength(10),\n regex: regex(/^\\+?[\\d\\s-()]+$/)\n }\n}))\n```\n\n## Single field validation\n\n```vue\n\n<template>\n <input v-model=\"r$.$value\" />\n <ul v-if=\"r$.$errors.length\">\n <li v-for=\"error of r$.$errors\" :key=\"error\">\n {{ error }}\n </li>\n </ul>\n</template>\n```\n\n## Custom Error Messages\n\n```ts\nimport {useRegle} from '@regle/core';\nimport { withMessage } from '@regle/rules'\n\nconst { r$ } = useRegle({email: '', password: ''}, {\n email: { \n required: withMessage(required, 'Email is required'),\n email: withMessage(email, 'Please enter a valid email address')\n },\n password: {\n minLength: withMessage(\n minLength(8), \n ({ $params: [min] }) => `Password must be at least ${min} characters`\n )\n }\n})\n```\n\n## Form Submission\n\n```ts\nimport {useRegle} from '@regle/core';\nimport {required} from '@regle/rules';\n\nconst {r$} = useRegle({name: ''}, {name: {required}});\n\nfunction handleSubmit() {\n // Validate entire form\n const {valid, data} = await r$.$validate()\n \n if (!valid) {\n console.log('Form has errors')\n return\n }\n \n // Submit data\n try {\n await submitForm(data)\n r$.$reset() // Reset form after success\n } catch (error) {\n // Handle submission error\n }\n}\n```\n\n## Collections (Arrays)\n\n```ts\nimport {useRegle} from '@regle/core';\nimport {required, email} from '@regle/rules';\n\nconst { r$ } = useRegle(\n { users: [{ name: '', email: '' }] },\n {\n users: {\n $each: {\n name: { required },\n email: { required, email }\n }\n }\n }\n)\n\n// Access array validation\nr$.users.$each[0].name.$error\n```\n\n## Nested Objects\n\n```ts\nimport {useRegle} from '@regle/core';\nimport {required, email, maxLength} from '@regle/rules';\n\nconst { r$ } = useRegle(\n { \n user: { \n profile: { name: '', bio: '' },\n contact: { email: '', phone: '' }\n }\n },\n {\n user: {\n profile: {\n name: { required },\n bio: { maxLength: maxLength(200) }\n },\n contact: {\n email: { required, email },\n phone: { required }\n }\n }\n }\n)\n\n// Access nested validation\nr$.user.profile.name.$error\n```\n\n## Global Configuration\n\n```ts\nimport { defineRegleConfig } from '@regle/core';\nimport { withMessage, required, minLength } from '@regle/rules';\n\n// Set up global defaults\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 modifiers: {\n rewardEarly: true,\n }\n})\n```\n\n## Schema Integration (Zod)\n\n```ts\nimport { z } from 'zod/v3'\nimport { useRegleSchema } from '@regle/schemas'\n\nconst schema = z.object({\n name: z.string().min(2),\n email: z.string().email(),\n age: z.number().min(18)\n})\n\nconst { r$ } = useRegleSchema({\n name: '',\n email: '',\n age: 0\n}, schema)\n```\n\n### TypeScript Errors?\n\n```ts\nimport { inferRules } from '@regle/core';\nimport { required } from '@regle/rules';\n\nconst state = ref({name: ''});\n\n// ✅ Use inferRules for better type inference\nconst rules = computed(() => {\n return inferRules(state, {\n name: { required }\n })\n})\n```"
|
|
72
|
+
"content": "# Regle Cheat Sheet\n\nQuick reference for common Regle patterns and usage scenarios.\n\n## Basic Setup\n\n```ts\nimport { useRegle } from '@regle/core'\nimport { required, email, minLength } from '@regle/rules'\n\nconst { r$ } = useRegle(\n { name: '', email: '' }, \n { \n name: { required, minLength: minLength(2) },\n email: { required, email }\n }\n)\n```\n\n## Essential Properties\n\n| Property | Description | Example |\n|----------|-------------|---------|\n| `r$.$value` | Form data (reactive) | `r$.$value.email` |\n| `r$.$correct` | Form is dirty and valid | `<button :disabled=\"!r$.$correct\">` |\n| `r$.$invalid` | Form is invalid | `v-if=\"r$.$invalid\"` |\n| `r$.$errors` | All error messages | `r$.$errors.email` |\n| `r$.x.$error` | Field has errors | `v-if=\"r$.email.$error\"` |\n| `r$.x.$correct` | Field is dirty and valid | `v-if=\"r$.email.$correct\"` |\n| `r$.x.$dirty` | Field was touched | `v-if=\"r$.email.$dirty\"` |\n| `r$.$validate()` | Validate form (async) | `await r$.$validate()` |\n| `r$.$validateSync()` | Validate form (sync, skips async rules) | `r$.$validateSync()` |\n| `r$.$reset()` | Reset form | `r$.$reset()` |\n\n## Common Rules\n\n```ts\nimport {useRegle} from '@regle/core';\nimport { \n required, email, minLength, maxLength,\n numeric, between, url, regex,\n alphaNum, alpha, sameAs\n} from '@regle/rules';\n\ntype FormState = {\n name?: string,\n email?: string,\n age?: number,\n username?: string,\n website?: string,\n description?: string,\n phone?: string,\n password?: string,\n confirmPassword?: string,\n}\n\nconst state = ref<FormState>({})\n\nconst { r$ } = useRegle(state, {\n // Basic validation\n name: { required, minLength: minLength(2) },\n email: { required, email },\n age: { required, numeric, between: between(18, 99) },\n \n // String validation\n username: { required, alphaNum, minLength: minLength(3) },\n website: { url },\n description: { maxLength: maxLength(500) },\n \n // Custom patterns\n phone: { regex: regex(/^\\+?[\\d\\s-()]+$/) },\n \n // Password confirmation\n password: { required, minLength: minLength(8) },\n confirmPassword: { \n required, \n sameAs: sameAs(() => state.value.password) \n }\n})\n```\n\n## Field Patterns\n\n### Basic Field with Error Display\n\n```vue\n<template>\n <div>\n <input v-model=\"r$.$value.email\" type=\"email\" />\n <span v-for=\"error of r$.email.$errors\" class=\"error\">\n {{ error }}\n </span>\n </div>\n</template>\n```\n\n### Field with Visual States\n```vue\n<template>\n <input \n v-model=\"r$.$value.email\"\n :class=\"{\n 'error': r$.email.$error,\n 'correct': r$.email.$correct,\n }\"\n />\n</template>\n```\n\n### Optional Field with Conditional Validation\n\n```ts \nimport {inferRules} from '@regle/core';\nimport {requiredIf, minLength, regex} from '@regle/rules';\n\nconst state = ref({phone: ''});\n\nconst rules = computed(() => inferRules(state, {\n phone: {\n // Only required if form have no email\n required: requiredIf(() => !r$.$value.email)\n minLength: minLength(10),\n regex: regex(/^\\+?[\\d\\s-()]+$/)\n }\n}))\n```\n\n## Single field validation\n\n```vue\n\n<template>\n <input v-model=\"r$.$value\" />\n <ul v-if=\"r$.$errors.length\">\n <li v-for=\"error of r$.$errors\" :key=\"error\">\n {{ error }}\n </li>\n </ul>\n</template>\n```\n\n## Custom Error Messages\n\n```ts\nimport {useRegle} from '@regle/core';\nimport { withMessage } from '@regle/rules'\n\nconst { r$ } = useRegle({email: '', password: ''}, {\n email: { \n required: withMessage(required, 'Email is required'),\n email: withMessage(email, 'Please enter a valid email address')\n },\n password: {\n minLength: withMessage(\n minLength(8), \n ({ $params: [min] }) => `Password must be at least ${min} characters`\n )\n }\n})\n```\n\n## Form Submission\n\n```ts\nimport {useRegle} from '@regle/core';\nimport {required} from '@regle/rules';\n\nconst {r$} = useRegle({name: ''}, {name: {required}});\n\nfunction handleSubmit() {\n // Validate entire form\n const {valid, data} = await r$.$validate()\n \n if (!valid) {\n console.log('Form has errors')\n return\n }\n \n // Submit data\n try {\n await submitForm(data)\n r$.$reset() // Reset form after success\n } catch (error) {\n // Handle submission error\n }\n}\n```\n\n## Collections (Arrays)\n\n```ts\nimport {useRegle} from '@regle/core';\nimport {required, email} from '@regle/rules';\n\nconst { r$ } = useRegle(\n { users: [{ name: '', email: '' }] },\n {\n users: {\n $each: {\n name: { required },\n email: { required, email }\n }\n }\n }\n)\n\n// Access array validation\nr$.users.$each[0].name.$error\n```\n\n## Nested Objects\n\n```ts\nimport {useRegle} from '@regle/core';\nimport {required, email, maxLength} from '@regle/rules';\n\nconst { r$ } = useRegle(\n { \n user: { \n profile: { name: '', bio: '' },\n contact: { email: '', phone: '' }\n }\n },\n {\n user: {\n profile: {\n name: { required },\n bio: { maxLength: maxLength(200) }\n },\n contact: {\n email: { required, email },\n phone: { required }\n }\n }\n }\n)\n\n// Access nested validation\nr$.user.profile.name.$error\n```\n\n## Global Configuration\n\n```ts\nimport { defineRegleConfig } from '@regle/core';\nimport { withMessage, required, minLength } from '@regle/rules';\n\n// Set up global defaults\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 modifiers: {\n rewardEarly: true,\n }\n})\n```\n\n## Schema Integration (Zod)\n\n```ts\nimport { z } from 'zod/v3'\nimport { useRegleSchema } from '@regle/schemas'\n\nconst schema = z.object({\n name: z.string().min(2),\n email: z.string().email(),\n age: z.number().min(18)\n})\n\nconst { r$ } = useRegleSchema({\n name: '',\n email: '',\n age: 0\n}, schema)\n```\n\n### TypeScript Errors?\n\n```ts\nimport { inferRules } from '@regle/core';\nimport { required } from '@regle/rules';\n\nconst state = ref({name: ''});\n\n// ✅ Use inferRules for better type inference\nconst rules = computed(() => {\n return inferRules(state, {\n name: { required }\n })\n})\n```"
|
|
73
73
|
},
|
|
74
74
|
{
|
|
75
75
|
"id": "common-usage-async-validation",
|
|
@@ -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### `$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
|
+
"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 [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.2
|
|
1937
|
+
var version = "1.18.2";
|
|
1938
1938
|
|
|
1939
1939
|
let posthogClient = null;
|
|
1940
1940
|
posthogClient = new PostHog("phc_kqgJoylCpKkGkkRGxb4MyN2mViehoQcUFEGwVkk4l8E", {
|