@regle/mcp-server 1.23.2 → 1.24.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.
@@ -138,7 +138,7 @@ const rawData = {
138
138
  "title": "Built-in rules",
139
139
  "category": "rules",
140
140
  "path": "core-concepts/rules/built-in-rules.md",
141
- "content": "# Built-in rules\n\nAll built-in rules are available through the `@regle/rules` package.\n\nDon't forget to install it if you haven't:\n\n::: code-group\n\n```sh [pnpm]\npnpm add @regle/rules\n```\n\n```sh [npm]\nnpm install @regle/rules\n```\n\n```sh [yarn]\nyarn add @regle/rules\n```\n\n```sh [bun]\nbun add @regle/rules\n```\n\n:::\n\n:::tip\nEvery built-in rule will check if the value of the field is set before checking if it's valid.\n\nThis allow to have rules even if the field is not required.\n:::\n\n## `alpha`\n\n_**Params**_\n - `allowSymbols?: MaybeRefOrGetter<boolean>`\n\nAllows only alphabetic characters.\n\n```ts\nimport { alpha } from '@regle/rules';\n\nconst { r$ } = useRegle({ name: '' }, {\n name: { \n alpha,\n // or\n alpha: alpha({ allowSymbols: true }),\n },\n})\n```\n\n## `alphaNum`\n\n_**Params**_\n - `allowSymbols?: MaybeRefOrGetter<boolean>`\n\nAllows only alphanumeric characters.\n\n```ts\nimport { useRegle } from '@regle/core';\nimport { alphaNum } from '@regle/rules';\n\nconst { r$ } = useRegle({ name: '' }, {\n name: { \n alphaNum,\n // or\n alphaNum: alphaNum({ allowSymbols: true }),\n },\n});\n```\n\n## `atLeastOne`\n\n_**Params**_\n - `keys?: MaybeRefOrGetter<string[]>` - Optional list of keys to check. If not provided, checks if the object has at least one filled property.\n\n_**Works with**_\n - `Record | object`\n\nChecks if at least one key is filled in the object. Useful for object-level validation with `$self`.\n\n```ts\nimport { atLeastOne } from '@regle/rules';\n\nconst { r$ } = useRegle({ user: { firstName: '', lastName: '' } }, {\n user: {\n $self: {\n // Check if any property is filled\n atLeastOne,\n // or check specific keys\n atLeastOne: atLeastOne(['firstName', 'lastName']),\n },\n },\n})\n```\n\n## `between`\n\n_**Params**_\n - `min: Ref<number> | number | () => number`\n - `max: Ref<number> | number | () => number`\n - `options?: {allowEqual?: boolean}`\n\nChecks if a number is in specified bounds. `min` and `max` are both inclusive.\n\n```ts\nimport { between } from '@regle/rules';\n\nconst maxCount = ref(6);\n\nconst { r$ } = useRegle({ count: 0 }, {\n count: {\n between: between(1, 6),\n between: between(1, maxCount, {allowEqual: false}),\n between: between(() => maxCount.value, 10)\n },\n})\n```\n\n## `boolean`\n\nRequires a value to be a native boolean type. Mainly used for typing.\n\n```ts\nimport {type InferInput} from '@regle/core';\nimport { boolean } from '@regle/rules';\n\nconst rules = {\n checkbox: { boolean },\n}\n\nconst state = ref<InferInput<typeof rules>>({});\n```\n\n## `checked`\n\nRequires a boolean value to be `true`. This is useful for checkbox inputs.\n\n### Note\n\nThis rule does not need `required` to be set, it will assert the value is set.\n\n```ts\nimport { checked } from '@regle/rules';\n\nconst { r$ } = useRegle({ confirm: false }, {\n confirm: { checked },\n})\n```\n\n## `contains`\n\n_**Params**_\n- `contain: Ref<string> | string | () => string`\n\nChecks if the string contains the specified substring.\n\n```ts\nimport { contains } from '@regle/rules';\n\nconst { r$ } = useRegle({ bestLib: '' }, {\n bestLib: {\n contains: contains('regle')\n },\n})\n```\n\n## `containsSpecialCharacter`\n\n_**Params**_\n- `minCharactersCount?: Ref<number> | number | () => number`\n\nRequires a string to contain at least a number of special characters.\n\n```ts\nimport { containsSpecialCharacter } from '@regle/rules';\n\nconst { r$ } = useRegle({ password: '' }, {\n password: {\n containsSpecialCharacter,\n // or with a custom minimum\n containsSpecialCharacter: containsSpecialCharacter(2),\n },\n})\n```\n\n## `containsUppercase`\n\n_**Params**_\n- `minUppercaseCount?: Ref<number> | number | () => number`\n\nRequires a string to contain at least a number of uppercase letters.\n\n```ts\nimport { containsUppercase } from '@regle/rules';\n\nconst { r$ } = useRegle({ password: '' }, {\n password: {\n containsUppercase,\n // or with a custom minimum\n containsUppercase: containsUppercase(2),\n },\n})\n```\n\n## `date`\n\nRequires a value to be a native Date constructor. Mainly used for typing.\n\n```ts\nimport {type InferInput} from '@regle/core';\nimport { date } from '@regle/rules';\n\nconst rules = {\n birthday: { date },\n}\n\nconst state = ref<InferInput<typeof rules>>({});\n```\n\n## `dateAfter`\n_**Params**_\n - `after: Ref<string | Date> | string | Date | () => string | Date`\n - `options?: {allowEqual?: boolean}`\n\nChecks if the date is after the given parameter.\n\n```ts\nimport { dateAfter } from '@regle/rules';\n\nconst today = ref(new Date());\n\nconst { r$ } = useRegle({ birthday: null as Date | null }, {\n birthday: {\n dateAfter: dateAfter(today),\n // or\n dateAfter: dateAfter(today, { allowEqual: false }),\n },\n})\n```\n\n## `dateBefore`\n_**Params**_\n - `before: Ref<string | Date> | string | Date | () => string | Date`\n - `options?: {allowEqual?: boolean}`\n\nChecks if the date is before the given parameter.\n\n```ts\nimport { dateBefore } from '@regle/rules';\n\nconst today = ref(new Date());\n\nconst { r$ } = useRegle({ birthday: null as Date | null }, {\n birthday: {\n dateBefore: dateBefore(today),\n // or\n dateBefore: dateBefore(today, { allowEqual: false }),\n },\n})\n```\n\n## `dateBetween`\n\n_**Params**_\n - `before: Ref<string | Date> | string | Date | () => string | Date`\n - `after: Ref<string | Date> | string | Date | () => string | Date`\n - `options?: {allowEqual?: boolean}`\n\nChecks if the date falls between the specified bounds.\n\n```ts\nimport { dateBetween } from '@regle/rules';\n\nconst before = ref(new Date());\nconst after = ref(new Date(2030, 3, 1));\n\nconst { r$ } = useRegle({ birthday: null as Date | null }, {\n birthday: {\n dateBetween: dateBetween(before, after),\n // or\n dateBetween: dateBetween(before, after, { allowEqual: false }),\n },\n})\n```\n\n## `decimal`\n\nAllows positive and negative decimal numbers.\n\n```ts\nimport { decimal } from '@regle/rules';\n\nconst { r$ } = useRegle({ price: 0 }, {\n price: { decimal },\n})\n```\n\n## `domain`\n\nValidates domain names only (for example `example.com` or `sub.example.com`).\n\n```ts\nimport { domain } from '@regle/rules';\n\nconst { r$ } = useRegle({ siteDomain: '' }, {\n siteDomain: { domain },\n})\n```\n\n## `email`\n\nValidates email addresses. Always verify on the server to ensure the address is real and not already in use.\n\n```ts\nimport { email } from '@regle/rules';\n\nconst { r$ } = useRegle({ email: '' }, {\n email: { email },\n})\n```\n\n## `emoji`\n\nValidates emojis.\n\n```ts\nimport { emoji } from '@regle/rules';\n\nconst { r$ } = useRegle({ emoji: '' }, {\n emoji: { emoji },\n})\n```\n\n## `endsWith`\n\n_**Params**_\n- `end: Ref<string> | string | () => string`\n\nChecks if the string ends with the specified substring.\n\n```ts\nimport { endsWith } from '@regle/rules';\n\nconst { r$ } = useRegle({ firstName: '' }, {\n firstName: { endsWith: endsWith('foo') },\n})\n```\n\n## `exactDigits`\n_**Params**_\n - `count: Ref<number> | number | () => number`\n\nRequires the input value to have a strict specified number of digits.\n\n```ts\nimport { exactDigits } from '@regle/rules';\n\nconst exactValue = ref(6);\n\nconst { r$ } = useRegle({ digits: '' }, {\n digits: {\n exactDigits: exactDigits(6),\n // or with ref\n exactDigits: exactDigits(exactValue),\n // or with getter\n exactDigits: exactDigits(() => exactValue.value)\n },\n})\n```\n\n## `exactLength`\n\n_**Params**_\n - `count: Ref<number> | number | () => number`\n\nRequires the input value to have a strict specified length, inclusive. Works with arrays, objects and strings.\n\n```ts\nimport { exactLength } from '@regle/rules';\n\nconst exactValue = ref(6);\n\nconst { r$ } = useRegle({ name: '' }, {\n name: {\n exactLength: exactLength(6),\n exactLength: exactLength(exactValue),\n exactLength: exactLength(() => exactValue.value)\n },\n})\n```\n\n## `exactValue`\n\n_**Params**_\n - `count: Ref<number> | number | () => number`\n\nRequires a field to have a strict numeric value.\n\n```ts\nimport { exactValue } from '@regle/rules';\n\nconst exactCount = ref(6);\n\nconst { r$ } = useRegle({ count: 0 }, {\n count: {\n exactValue: exactValue(6),\n exactValue: exactValue(exactCount),\n exactValue: exactValue(() => exactCount.value)\n },\n})\n```\n\n## `file`\n\nRequires a value to be a native File constructor. Mainly used for typing.\n\n```ts\nimport { file } from '@regle/rules';\n\nconst rules = {\n file: { file },\n}\n\nconst state = ref<InferInput<typeof rules>>({});\n```\n\n## `fileType`\n\nRequires a value to be a file with a specific type.\n\n```ts\nimport { fileType } from '@regle/rules';\n\nconst { r$ } = useRegle({ file: null as File | null }, {\n file: { fileType: fileType(['image/png', 'image/jpeg']) },\n})\n```\n\n## `hexadecimal`\n\nValidates hexadecimal values.\n\n```ts\nimport { hexadecimal } from '@regle/rules';\n\nconst { r$ } = useRegle({ hexadecimal: '' }, {\n hexadecimal: { hexadecimal },\n})\n```\n\n## `hostname`\n\nValidates hostnames.\n\n```ts\nimport { hostname } from '@regle/rules';\n\nconst { r$ } = useRegle({ siteHost: '' }, {\n siteHost: { hostname },\n})\n```\n\n## `httpUrl`\n\n_**Params**_\n- `options?: {protocol?: RegExp}`\n\nValidates HTTP URLs.\n\n```ts\nimport { httpUrl } from '@regle/rules';\n\nconst { r$ } = useRegle({ bestUrl: '' }, {\n bestUrl: { httpUrl },\n // or with custom protocol validation\n bestUrl: { httpUrl: httpUrl({ protocol: /^https$/ }) },\n})\n```\n\n## `integer`\n\nAllows only integers (positive and negative).\n\n```ts\nimport { integer } from '@regle/rules';\n\nconst { r$ } = useRegle({ count: 0 }, {\n count: { integer },\n})\n```\n\n## `ipv4Address`\n\nValidates IPv4 addresses in dotted decimal notation *127.0.0.1*.\n\n```ts\nimport { ipv4Address } from '@regle/rules';\n\nconst { r$ } = useRegle({ address: '' }, {\n address: { ipv4Address },\n})\n```\n\n<Ipv4AddressDemo />\n\n## `literal`\n\nValidates literal values.\n\n### Note\n\nThis rule does not need `required` to be set, it will assert the value is set.\n\n```ts\nimport { literal } from '@regle/rules';\n\nconst { r$ } = useRegle({ value: '' }, {\n value: { literal: literal('foo') },\n})\n```\n\n## `lowercase`\n\nValidates lowercase strings.\n\n```ts\nimport { lowercase } from '@regle/rules';\n\nconst { r$ } = useRegle({ name: '' }, {\n name: { lowercase },\n})\n```\n\n## `macAddress`\n\n_**Params**_\n - `separator?: string | Ref<string> | () => string`\n\nValidates MAC addresses. Call as a function to specify a custom separator (e.g., ':' or an empty string for 00ff1122334455).\n\n```ts\nimport { useRegle } from '@regle/core';\nimport { macAddress } from '@regle/rules';\n\nconst { r$ } = useRegle({ address: '' }, {\n address: {\n macAddress,\n // or\n macAddress: macAddress('-')\n },\n});\n```\n\n## `maxFileSize`\n\nRequires a value to be a file with a maximum size.\n\n```ts\nimport { maxFileSize } from '@regle/rules';\n\nconst { r$ } = useRegle({ file: null as File | null }, {\n file: { maxFileSize: maxFileSize(10_000_000) }, // 10 MB\n})\n```\n\n## `maxLength`\n\n_**Params**_\n - `max: Ref<number> | number | () => number`\n - `options?: {allowEqual?: boolean}`\n\n_**Works with**_\n - `Array | Record | string | number`\n\nRequires the input value to have a maximum specified length, inclusive. Works with arrays, objects and strings.\n\n```ts\nimport { maxLength } from '@regle/rules';\n\nconst maxValue = ref(6);\n\nconst { r$ } = useRegle({ name: '' }, {\n name: {\n maxLength: maxLength(6),\n maxLength: maxLength(maxValue),\n maxLength: maxLength(() => maxValue.value)\n },\n})\n```\n\n## `maxValue`\n\n_**Params**_\n - `min: Ref<number> | number | () => number`\n - `options?: {allowEqual?: boolean}`\n\n Requires a field to have a specified maximum numeric value.\n\n```ts\nimport { maxValue } from '@regle/rules';\n\nconst maxCount = ref(6);\n\nconst { r$ } = useRegle({ count: 0 }, {\n count: {\n maxValue: maxValue(6),\n maxValue: maxValue(maxCount, {allowEqual: false}),\n maxValue: maxValue(() => maxCount.value)\n },\n})\n```\n\n## `minFileSize`\n\nRequires a value to be a file with a minimum size.\n\n```ts\nimport { minFileSize } from '@regle/rules';\n\nconst { r$ } = useRegle({ file: null as File | null }, {\n file: { minFileSize: minFileSize(1_000_000) }, // 1 MB\n})\n```\n\n## `minLength`\n\n_**Params**_\n - `min: Ref<number> | number | () => number`\n - `options?: {allowEqual?: boolean}`\n\n_**Works with**_\n - `Array | Record | string | number`\n\nRequires the input value to have a minimum specified length, inclusive. Works with arrays, objects and strings.\n\n```ts\nimport { minLength } from '@regle/rules';\n\nconst minValue = ref(6);\n\nconst { r$ } = useRegle({ name: '' }, {\n name: {\n minLength: minLength(6),\n minLength: minLength(minValue),\n minLength: minLength(() => minValue.value)\n },\n})\n```\n\n## `minValue`\n\n_**Params**_\n - `min: Ref<number> | number | () => number`\n - `options?: {allowEqual?: boolean}`\n\n_**Works with**_\n - `number`\n\nRequires a field to have a specified minimum numeric value.\n\n```ts\nimport { minValue } from '@regle/rules';\n\nconst minCount = ref(6);\n\nconst { r$ } = useRegle({ count: 0 }, {\n count: {\n minValue: minValue(6),\n minValue: minValue(minCount, {allowEqual: false}),\n minValue: minValue(() => minCount.value)\n },\n})\n```\n\n## `nativeEnum`\n\nValidate against a native Typescript enum value. Similar to Zod's `nativeEnum`\n\n```ts\nimport { nativeEnum } from '@regle/rules';\n\nenum Foo {\n Bar, Baz\n}\n\nconst { r$ } = useRegle({ type: '' }, {\n type: { nativeEnum: nativeEnum(Foo) },\n})\n```\n\n## `number`\n\nRequires a value to be a native number type. Mainly used for typing.\n\n```ts\nimport { number } from '@regle/rules';\n\nconst rules = {\n count: { number },\n}\n\nconst state = ref<InferInput<typeof rules>>({});\n```\n\n## `numeric`\n\nAllows only numeric values (including numeric strings).\n\n```ts\nimport { numeric } from '@regle/rules';\n\nconst { r$ } = useRegle({ count: 0 }, {\n count: { numeric },\n})\n```\n\n## `oneOf`\n\nAllow only one of the values from a fixed Array of possible entries.\n\n_**Params**_\n - `options: MaybeRefOrGetter<Array<string | number>>`\n\n```ts\nimport { oneOf } from '@regle/rules';\n\nconst foodEnum = {\n Fish: 'Fish',\n Meat: 'Meat',\n Bone: 'Bone',\n} as const;\n\nconst { r$ } = useRegle({ aliment: 'Fish' }, {\n aliment: {\n oneOf: oneOf(['Fish', 'Meat', 'Bone']),\n // or\n oneOf: oneOf(foodEnum),\n },\n})\n```\n\n## `regex`\n\n_**Params**_\n- `regexps: MaybeRefOrGetter<RegExp | RegExp[]>`\n\nChecks if the value matches one or more regular expressions.\n\n```ts\nimport { regex } from '@regle/rules';\n\nconst { r$ } = useRegle({ name: '' }, {\n name: {\n regex: regex(/^foo/),\n regex: regex([/^bar/, /baz$/]),\n },\n})\n```\n\n## `required`\n\nRequires non-empty data. Checks for empty arrays and strings containing only whitespaces.\n\n```ts\nimport {required} from '@regle/rules';\n\nconst {r$} = useRegle({name: ''}, {\n name: {required},\n})\n```\n\n## `requiredIf`\n\n_**Params**_\n - `condition: Ref<unknown> | unknown | () => unknown` - the property to base the `required` validator on.\n\nRequires non-empty data, only if provided data property, ref, or a function resolves to `true`.\n\n```ts\nimport { requiredIf } from '@regle/rules';\n\nconst form = ref({ name: '', condition: false });\n\nconst conditionRef = ref(false);\n\nconst { r$ } = useRegle(form, {\n name: {\n required: requiredIf(() => form.value.condition),\n required: requiredIf(conditionRef),\n },\n})\n```\n\n## `requiredUnless`\n\n_**Params**_\n - `condition: Ref<unknown> | unknown | () => unknown` - the property to base the `required` validator on.\n\nRequires non-empty data, only if provided data property, ref, or a function resolves to `false`.\n\n```ts\nimport { requiredUnless } from '@regle/rules';\n\nconst form = ref({ name: '', condition: false });\n\nconst conditionRef = ref(false);\n\nconst { r$ } = useRegle(form, {\n name: {\n required: requiredUnless(() => form.value.condition),\n required: requiredUnless(conditionRef)\n },\n})\n```\n\n## `sameAs`\n\n_**Params**_\n * `target: unknown`\n\nChecks if the value matches the specified property or ref.\n\n```ts\nimport { sameAs } from '@regle/rules';\n\nconst form = ref({\n password: '',\n confirmPassword: '',\n});\n\nconst { r$ } = useRegle(form, {\n confirmPassword: {\n sameAs: sameAs(() => form.value.password),\n }\n})\n```\n\n## `startsWith`\n\n_**Params**_\n- `start: Ref<string> | string | () => string`\n\nChecks if the string starts with the specified substring.\n\n```ts\nimport { startsWith } from '@regle/rules';\n\nconst { r$ } = useRegle({ bestLib: '' }, {\n bestLib: {\n startsWith: startsWith('regle')\n },\n})\n```\n\n## `string`\n\nRequires a value to be a native string type. Mainly used for typing\n\n```ts\nimport {type InferInput} from '@regle/core';\nimport { string } from '@regle/rules';\n\nconst rules = {\n firstName: { string },\n}\n\nconst state = ref<InferInput<typeof rules>>({});\n```\n\n## `type`\n\nDefine the input type of a rule. No runtime validation. \nOverride any input type set by other rules.\n\n```ts\nimport {type InferInput} from '@regle/core';\nimport { type } from '@regle/rules';\n\nconst rules = {\n firstName: { type: type<string>() },\n}\n\nconst state = ref<InferInput<typeof rules>>({});\n```\n\n## `uppercase`\n\nValidates uppercase strings.\n\n```ts\nimport { uppercase } from '@regle/rules';\n\nconst { r$ } = useRegle({ name: '' }, {\n name: { uppercase },\n})\n```\n\n## `url`\n\n_**Params**_\n- `options?: {protocol?: RegExp}`\n\nValidates URLs.\n\n```ts\nimport { url } from '@regle/rules';\n\nconst { r$ } = useRegle({ bestUrl: '' }, {\n bestUrl: { url },\n // or with custom protocol validation\n bestUrl: { url: url({ protocol: /^https?$/ }) },\n})\n```"
141
+ "content": "# Built-in rules\n\nAll built-in rules are available through the `@regle/rules` package.\n\nDon't forget to install it if you haven't:\n\n::: code-group\n\n```sh [pnpm]\npnpm add @regle/rules\n```\n\n```sh [npm]\nnpm install @regle/rules\n```\n\n```sh [yarn]\nyarn add @regle/rules\n```\n\n```sh [bun]\nbun add @regle/rules\n```\n\n:::\n\n:::tip\nEvery built-in rule will check if the value of the field is set before checking if it's valid.\n\nThis allow to have rules even if the field is not required.\n:::\n\n## `alpha`\n\n_**Params**_\n - `allowSymbols?: MaybeRefOrGetter<boolean>`\n\nAllows only alphabetic characters.\n\n```ts\nimport { alpha } from '@regle/rules';\n\nconst { r$ } = useRegle({ name: '' }, {\n name: { \n alpha,\n // or\n alpha: alpha({ allowSymbols: true }),\n },\n})\n```\n\n## `alphaNum`\n\n_**Params**_\n - `allowSymbols?: MaybeRefOrGetter<boolean>`\n\nAllows only alphanumeric characters.\n\n```ts\nimport { useRegle } from '@regle/core';\nimport { alphaNum } from '@regle/rules';\n\nconst { r$ } = useRegle({ name: '' }, {\n name: { \n alphaNum,\n // or\n alphaNum: alphaNum({ allowSymbols: true }),\n },\n});\n```\n\n## `atLeastOne`\n\n_**Params**_\n - `keys?: MaybeRefOrGetter<string[]>` - Optional list of keys to check. If not provided, checks if the object has at least one filled property.\n\n_**Works with**_\n - `Record | object`\n\nChecks if at least one key is filled in the object. Useful for object-level validation with `$self`.\n\n```ts\nimport { atLeastOne } from '@regle/rules';\n\nconst { r$ } = useRegle({ user: { firstName: '', lastName: '' } }, {\n user: {\n $self: {\n // Check if any property is filled\n atLeastOne,\n // or check specific keys\n atLeastOne: atLeastOne(['firstName', 'lastName']),\n },\n },\n})\n```\n\n## `between`\n\n_**Params**_\n - `min: Ref<number> | number | () => number`\n - `max: Ref<number> | number | () => number`\n - `options?: {allowEqual?: boolean}`\n\nChecks if a number is in specified bounds. `min` and `max` are both inclusive.\n\n```ts\nimport { between } from '@regle/rules';\n\nconst maxCount = ref(6);\n\nconst { r$ } = useRegle({ count: 0 }, {\n count: {\n between: between(1, 6),\n between: between(1, maxCount, {allowEqual: false}),\n between: between(() => maxCount.value, 10)\n },\n})\n```\n\n## `boolean`\n\nRequires a value to be a native boolean type. Mainly used for typing.\n\n```ts\nimport {type InferInput} from '@regle/core';\nimport { boolean } from '@regle/rules';\n\nconst rules = {\n checkbox: { boolean },\n}\n\nconst state = ref<InferInput<typeof rules>>({});\n```\n\n## `checked`\n\nRequires a boolean value to be `true`. This is useful for checkbox inputs.\n\n### Note\n\nThis rule does not need `required` to be set, it will assert the value is set.\n\n```ts\nimport { checked } from '@regle/rules';\n\nconst { r$ } = useRegle({ confirm: false }, {\n confirm: { checked },\n})\n```\n\n## `contains`\n\n_**Params**_\n- `contain: Ref<string> | string | () => string`\n\nChecks if the string contains the specified substring.\n\n```ts\nimport { contains } from '@regle/rules';\n\nconst { r$ } = useRegle({ bestLib: '' }, {\n bestLib: {\n contains: contains('regle')\n },\n})\n```\n\n## `containsSpecialCharacter`\n\n_**Params**_\n- `minCharactersCount?: Ref<number> | number | () => number`\n\nRequires a string to contain at least a number of special characters.\n\n```ts\nimport { containsSpecialCharacter } from '@regle/rules';\n\nconst { r$ } = useRegle({ password: '' }, {\n password: {\n containsSpecialCharacter,\n // or with a custom minimum\n containsSpecialCharacter: containsSpecialCharacter(2),\n },\n})\n```\n\n## `containsUppercase`\n\n_**Params**_\n- `minUppercaseCount?: Ref<number> | number | () => number`\n\nRequires a string to contain at least a number of uppercase letters.\n\n```ts\nimport { containsUppercase } from '@regle/rules';\n\nconst { r$ } = useRegle({ password: '' }, {\n password: {\n containsUppercase,\n // or with a custom minimum\n containsUppercase: containsUppercase(2),\n },\n})\n```\n\n## `date`\n\nRequires a value to be a native Date constructor. Mainly used for typing.\n\n```ts\nimport {type InferInput} from '@regle/core';\nimport { date } from '@regle/rules';\n\nconst rules = {\n birthday: { date },\n}\n\nconst state = ref<InferInput<typeof rules>>({});\n```\n\n## `dateAfter`\n_**Params**_\n - `after: Ref<string | Date> | string | Date | () => string | Date`\n - `options?: {allowEqual?: boolean}`\n\nChecks if the date is after the given parameter.\n\n```ts\nimport { dateAfter } from '@regle/rules';\n\nconst today = ref(new Date());\n\nconst { r$ } = useRegle({ birthday: null as Date | null }, {\n birthday: {\n dateAfter: dateAfter(today),\n // or\n dateAfter: dateAfter(today, { allowEqual: false }),\n },\n})\n```\n\n## `dateBefore`\n_**Params**_\n - `before: Ref<string | Date> | string | Date | () => string | Date`\n - `options?: {allowEqual?: boolean}`\n\nChecks if the date is before the given parameter.\n\n```ts\nimport { dateBefore } from '@regle/rules';\n\nconst today = ref(new Date());\n\nconst { r$ } = useRegle({ birthday: null as Date | null }, {\n birthday: {\n dateBefore: dateBefore(today),\n // or\n dateBefore: dateBefore(today, { allowEqual: false }),\n },\n})\n```\n\n## `dateBetween`\n\n_**Params**_\n - `before: Ref<string | Date> | string | Date | () => string | Date`\n - `after: Ref<string | Date> | string | Date | () => string | Date`\n - `options?: {allowEqual?: boolean}`\n\nChecks if the date falls between the specified bounds.\n\n```ts\nimport { dateBetween } from '@regle/rules';\n\nconst before = ref(new Date());\nconst after = ref(new Date(2030, 3, 1));\n\nconst { r$ } = useRegle({ birthday: null as Date | null }, {\n birthday: {\n dateBetween: dateBetween(before, after),\n // or\n dateBetween: dateBetween(before, after, { allowEqual: false }),\n },\n})\n```\n\n## `decimal`\n\nAllows positive and negative decimal numbers.\n\n```ts\nimport { decimal } from '@regle/rules';\n\nconst { r$ } = useRegle({ price: 0 }, {\n price: { decimal },\n})\n```\n\n## `domain`\n\nValidates domain names only (for example `example.com` or `sub.example.com`).\n\n```ts\nimport { domain } from '@regle/rules';\n\nconst { r$ } = useRegle({ siteDomain: '' }, {\n siteDomain: { domain },\n})\n```\n\n## `email`\n\nValidates email addresses. Always verify on the server to ensure the address is real and not already in use.\n\n```ts\nimport { email } from '@regle/rules';\n\nconst { r$ } = useRegle({ email: '' }, {\n email: { email },\n})\n```\n\n## `emoji`\n\nValidates emojis.\n\n```ts\nimport { emoji } from '@regle/rules';\n\nconst { r$ } = useRegle({ emoji: '' }, {\n emoji: { emoji },\n})\n```\n\n## `endsWith`\n\n_**Params**_\n- `end: Ref<string> | string | () => string`\n\nChecks if the string ends with the specified substring.\n\n```ts\nimport { endsWith } from '@regle/rules';\n\nconst { r$ } = useRegle({ firstName: '' }, {\n firstName: { endsWith: endsWith('foo') },\n})\n```\n\n## `exactDigits`\n_**Params**_\n - `count: Ref<number> | number | () => number`\n\nRequires the input value to have a strict specified number of digits.\n\n```ts\nimport { exactDigits } from '@regle/rules';\n\nconst exactValue = ref(6);\n\nconst { r$ } = useRegle({ digits: '' }, {\n digits: {\n exactDigits: exactDigits(6),\n // or with ref\n exactDigits: exactDigits(exactValue),\n // or with getter\n exactDigits: exactDigits(() => exactValue.value)\n },\n})\n```\n\n## `exactLength`\n\n_**Params**_\n - `count: Ref<number> | number | () => number`\n\n_**Works with**_\n - `Array | Record | string | number`\n\nRequires the input value to have a strict specified length.\n\n```ts\nimport { exactLength } from '@regle/rules';\n\nconst exactValue = ref(6);\n\nconst { r$ } = useRegle({ name: '' }, {\n name: {\n exactLength: exactLength(6),\n exactLength: exactLength(exactValue),\n exactLength: exactLength(() => exactValue.value)\n },\n})\n```\n\n## `exactValue`\n\n_**Params**_\n - `count: Ref<number> | number | () => number`\n\nRequires a field to have a strict numeric value.\n\n```ts\nimport { exactValue } from '@regle/rules';\n\nconst exactCount = ref(6);\n\nconst { r$ } = useRegle({ count: 0 }, {\n count: {\n exactValue: exactValue(6),\n exactValue: exactValue(exactCount),\n exactValue: exactValue(() => exactCount.value)\n },\n})\n```\n\n## `file`\n\nRequires a value to be a native File constructor. Mainly used for typing.\n\n```ts\nimport { file } from '@regle/rules';\n\nconst rules = {\n file: { file },\n}\n\nconst state = ref<InferInput<typeof rules>>({});\n```\n\n## `fileType`\n\nRequires a value to be a file with a specific type.\n\n```ts\nimport { fileType } from '@regle/rules';\n\nconst { r$ } = useRegle({ file: null as File | null }, {\n file: { fileType: fileType(['image/png', 'image/jpeg']) },\n})\n```\n\n## `hexadecimal`\n\nValidates hexadecimal values.\n\n```ts\nimport { hexadecimal } from '@regle/rules';\n\nconst { r$ } = useRegle({ hexadecimal: '' }, {\n hexadecimal: { hexadecimal },\n})\n```\n\n## `hostname`\n\nValidates hostnames.\n\n```ts\nimport { hostname } from '@regle/rules';\n\nconst { r$ } = useRegle({ siteHost: '' }, {\n siteHost: { hostname },\n})\n```\n\n## `httpUrl`\n\n_**Params**_\n- `options?: {protocol?: RegExp}`\n\nValidates HTTP URLs.\n\n```ts\nimport { httpUrl } from '@regle/rules';\n\nconst { r$ } = useRegle({ bestUrl: '' }, {\n bestUrl: { httpUrl },\n // or with custom protocol validation\n bestUrl: { httpUrl: httpUrl({ protocol: /^https$/ }) },\n})\n```\n\n## `integer`\n\nAllows only integers (positive and negative).\n\n```ts\nimport { integer } from '@regle/rules';\n\nconst { r$ } = useRegle({ count: 0 }, {\n count: { integer },\n})\n```\n\n## `ipv4Address`\n\nValidates IPv4 addresses in dotted decimal notation *127.0.0.1*.\n\n```ts\nimport { ipv4Address } from '@regle/rules';\n\nconst { r$ } = useRegle({ address: '' }, {\n address: { ipv4Address },\n})\n```\n\n<Ipv4AddressDemo />\n\n## `literal`\n\nValidates literal values.\n\n### Note\n\nThis rule does not need `required` to be set, it will assert the value is set.\n\n```ts\nimport { literal } from '@regle/rules';\n\nconst { r$ } = useRegle({ value: '' }, {\n value: { literal: literal('foo') },\n})\n```\n\n## `lowercase`\n\nValidates lowercase strings.\n\n```ts\nimport { lowercase } from '@regle/rules';\n\nconst { r$ } = useRegle({ name: '' }, {\n name: { lowercase },\n})\n```\n\n## `macAddress`\n\n_**Params**_\n - `separator?: string | Ref<string> | () => string`\n\nValidates MAC addresses. Call as a function to specify a custom separator (e.g., ':' or an empty string for 00ff1122334455).\n\n```ts\nimport { useRegle } from '@regle/core';\nimport { macAddress } from '@regle/rules';\n\nconst { r$ } = useRegle({ address: '' }, {\n address: {\n macAddress,\n // or\n macAddress: macAddress('-')\n },\n});\n```\n\n## `maxFileSize`\n\nRequires a value to be a file with a maximum size.\n\n```ts\nimport { maxFileSize } from '@regle/rules';\n\nconst { r$ } = useRegle({ file: null as File | null }, {\n file: { maxFileSize: maxFileSize(10_000_000) }, // 10 MB\n})\n```\n\n## `maxLength`\n\n_**Params**_\n - `max: Ref<number> | number | () => number`\n - `options?: {allowEqual?: boolean}`\n\n_**Works with**_\n - `Array | Record | string | number`\n\nRequires the input value to have a maximum specified length, inclusive.\n\n```ts\nimport { maxLength } from '@regle/rules';\n\nconst maxValue = ref(6);\n\nconst { r$ } = useRegle({ name: '' }, {\n name: {\n maxLength: maxLength(6),\n maxLength: maxLength(maxValue),\n maxLength: maxLength(() => maxValue.value)\n },\n})\n```\n\n## `maxValue`\n\n_**Params**_\n - `min: Ref<number> | number | () => number`\n - `options?: {allowEqual?: boolean}`\n\n Requires a field to have a specified maximum numeric value.\n\n```ts\nimport { maxValue } from '@regle/rules';\n\nconst maxCount = ref(6);\n\nconst { r$ } = useRegle({ count: 0 }, {\n count: {\n maxValue: maxValue(6),\n maxValue: maxValue(maxCount, {allowEqual: false}),\n maxValue: maxValue(() => maxCount.value)\n },\n})\n```\n\n## `minFileSize`\n\nRequires a value to be a file with a minimum size.\n\n```ts\nimport { minFileSize } from '@regle/rules';\n\nconst { r$ } = useRegle({ file: null as File | null }, {\n file: { minFileSize: minFileSize(1_000_000) }, // 1 MB\n})\n```\n\n## `minLength`\n\n_**Params**_\n - `min: Ref<number> | number | () => number`\n - `options?: {allowEqual?: boolean}`\n\n_**Works with**_\n - `Array | Record | string | number`\n\nRequires the input value to have a minimum specified length, inclusive.\n\n```ts\nimport { minLength } from '@regle/rules';\n\nconst minValue = ref(6);\n\nconst { r$ } = useRegle({ name: '' }, {\n name: {\n minLength: minLength(6),\n minLength: minLength(minValue),\n minLength: minLength(() => minValue.value)\n },\n})\n```\n\n## `minValue`\n\n_**Params**_\n - `min: Ref<number> | number | () => number`\n - `options?: {allowEqual?: boolean}`\n\n_**Works with**_\n - `number`\n\nRequires a field to have a specified minimum numeric value.\n\n```ts\nimport { minValue } from '@regle/rules';\n\nconst minCount = ref(6);\n\nconst { r$ } = useRegle({ count: 0 }, {\n count: {\n minValue: minValue(6),\n minValue: minValue(minCount, {allowEqual: false}),\n minValue: minValue(() => minCount.value)\n },\n})\n```\n\n## `nativeEnum`\n\nValidate against a native Typescript enum value. Similar to Zod's `nativeEnum`\n\n```ts\nimport { nativeEnum } from '@regle/rules';\n\nenum Foo {\n Bar, Baz\n}\n\nconst { r$ } = useRegle({ type: '' }, {\n type: { nativeEnum: nativeEnum(Foo) },\n})\n```\n\n## `number`\n\nRequires a value to be a native number type. Mainly used for typing.\n\n```ts\nimport { number } from '@regle/rules';\n\nconst rules = {\n count: { number },\n}\n\nconst state = ref<InferInput<typeof rules>>({});\n```\n\n## `numeric`\n\nAllows only numeric values (including numeric strings).\n\n```ts\nimport { numeric } from '@regle/rules';\n\nconst { r$ } = useRegle({ count: 0 }, {\n count: { numeric },\n})\n```\n\n## `oneOf`\n\nAllow only one of the values from a fixed Array of possible entries.\n\n_**Params**_\n - `options: MaybeRefOrGetter<Array<string | number>>`\n\n```ts\nimport { oneOf } from '@regle/rules';\n\nconst foodEnum = {\n Fish: 'Fish',\n Meat: 'Meat',\n Bone: 'Bone',\n} as const;\n\nconst { r$ } = useRegle({ aliment: 'Fish' }, {\n aliment: {\n oneOf: oneOf(['Fish', 'Meat', 'Bone']),\n // or\n oneOf: oneOf(foodEnum),\n },\n})\n```\n\n## `regex`\n\n_**Params**_\n- `regexps: MaybeRefOrGetter<RegExp | RegExp[]>`\n\nChecks if the value matches one or more regular expressions.\n\n```ts\nimport { regex } from '@regle/rules';\n\nconst { r$ } = useRegle({ name: '' }, {\n name: {\n regex: regex(/^foo/),\n regex: regex([/^bar/, /baz$/]),\n },\n})\n```\n\n## `required`\n\nRequires non-empty data. Checks for empty arrays and strings containing only whitespaces.\n\n```ts\nimport {required} from '@regle/rules';\n\nconst {r$} = useRegle({name: ''}, {\n name: {required},\n})\n```\n\n## `requiredIf`\n\n_**Params**_\n - `condition: Ref<unknown> | unknown | () => unknown` - the property to base the `required` validator on.\n\nRequires non-empty data, only if provided data property, ref, or a function resolves to `true`.\n\n```ts\nimport { requiredIf } from '@regle/rules';\n\nconst form = ref({ name: '', condition: false });\n\nconst conditionRef = ref(false);\n\nconst { r$ } = useRegle(form, {\n name: {\n required: requiredIf(() => form.value.condition),\n required: requiredIf(conditionRef),\n },\n})\n```\n\n## `requiredUnless`\n\n_**Params**_\n - `condition: Ref<unknown> | unknown | () => unknown` - the property to base the `required` validator on.\n\nRequires non-empty data, only if provided data property, ref, or a function resolves to `false`.\n\n```ts\nimport { requiredUnless } from '@regle/rules';\n\nconst form = ref({ name: '', condition: false });\n\nconst conditionRef = ref(false);\n\nconst { r$ } = useRegle(form, {\n name: {\n required: requiredUnless(() => form.value.condition),\n required: requiredUnless(conditionRef)\n },\n})\n```\n\n## `sameAs`\n\n_**Params**_\n * `target: unknown`\n\nChecks if the value matches the specified property or ref.\n\n```ts\nimport { sameAs } from '@regle/rules';\n\nconst form = ref({\n password: '',\n confirmPassword: '',\n});\n\nconst { r$ } = useRegle(form, {\n confirmPassword: {\n sameAs: sameAs(() => form.value.password),\n }\n})\n```\n\n## `startsWith`\n\n_**Params**_\n- `start: Ref<string> | string | () => string`\n\nChecks if the string starts with the specified substring.\n\n```ts\nimport { startsWith } from '@regle/rules';\n\nconst { r$ } = useRegle({ bestLib: '' }, {\n bestLib: {\n startsWith: startsWith('regle')\n },\n})\n```\n\n## `string`\n\nRequires a value to be a native string type. Mainly used for typing\n\n```ts\nimport {type InferInput} from '@regle/core';\nimport { string } from '@regle/rules';\n\nconst rules = {\n firstName: { string },\n}\n\nconst state = ref<InferInput<typeof rules>>({});\n```\n\n## `type`\n\nDefine the input type of a rule. No runtime validation. \nOverride any input type set by other rules.\n\n```ts\nimport {type InferInput} from '@regle/core';\nimport { type } from '@regle/rules';\n\nconst rules = {\n firstName: { type: type<string>() },\n}\n\nconst state = ref<InferInput<typeof rules>>({});\n```\n\n## `uppercase`\n\nValidates uppercase strings.\n\n```ts\nimport { uppercase } from '@regle/rules';\n\nconst { r$ } = useRegle({ name: '' }, {\n name: { uppercase },\n})\n```\n\n## `url`\n\n_**Params**_\n- `options?: {protocol?: RegExp}`\n\nValidates URLs.\n\n```ts\nimport { url } from '@regle/rules';\n\nconst { r$ } = useRegle({ bestUrl: '' }, {\n bestUrl: { url },\n // or with custom protocol validation\n bestUrl: { url: url({ protocol: /^https?$/ }) },\n})\n```"
142
142
  },
143
143
  {
144
144
  "id": "core-concepts-rules-index",
@@ -180,7 +180,7 @@ const rawData = {
180
180
  "title": "Validations helpers",
181
181
  "category": "rules",
182
182
  "path": "core-concepts/rules/validations-helpers.md",
183
- "content": "# Validations helpers\n\nWhen writing custom rules, some checks or validations can become tedious, especially when handling values that might be null, undefined, or unset. It's also a best practice to verify whether a field is \"filled\" before proceeding with validation.\n\nTo simplify this process, Regle provides a set of utility functions to assist in creating custom rules.\n\nThese utilities can be accessed via:\n\n```ts\nimport { isFilled, isEmpty, getSize, ... } from '@regle/rules';\n```\n\n## Runtime and Type guards\n\n### `isFilled`\n\n_**Params**_\n - `value: unknown`\n - `considerEmptyArrayInvalid = true`\n\nThis is almost a must have for optional fields. It checks if any value you provided is defined (including arrays and objects).\nYou can base your validator result on this.\n\n`isFilled` also acts as a type guard.\n\nBy default, it considers empty array as `false`. You can override this behaviour with the `considerEmptyArrayInvalid`\n\n```ts\nimport { createRule } from '@regle/core';\nimport { isFilled } from '@regle/rules';\n\nconst rule = createRule({\n validator(value: unknown) {\n if (isFilled(value)) {\n return check(value);\n }\n return true;\n },\n message: 'Error'\n})\n```\n\n### `isEmpty`\n\n_**Params**_\n - `value: unknown`\n - `considerEmptyArrayInvalid = true`\n\nThis is the inverse of `isFilled`. It will check if the value is in any way empty (including arrays and objects)\n\n`isEmpty` also acts as a type guard.\n\nBy default, it considers empty array as `true`. You can override this behaviour with the `considerEmptyArrayInvalid`\n\n```ts\nimport { createRule, type Maybe } from '@regle/core';\nimport { isEmpty } from '@regle/rules';\n\nconst rule = createRule({\n validator(value: Maybe<string>) {\n if (isEmpty(value)) {\n return true;\n }\n return check(value);\n },\n message: 'Error'\n})\n```\n\n### `isNumber`\n\nThis is a type guard that will check if the passed value is a real `Number`.\nThis also returns false for `NaN`, so this is better than `typeof value === \"number\"`.\n\n```ts\nimport { createRule, type Maybe } from '@regle/core';\nimport { isFilled, isNumber } from '@regle/rules';\n\nconst rule = createRule({\n validator(value: Maybe<number | string>) {\n if (isFilled(value) && isNumber(value)) {\n return checkNumber(value);\n }\n return true;\n },\n message: 'Error'\n})\n```\n\n### `isDate`\n\nThis is a useful helper that can check if the provided value is a Date, it is used internally for `date` rules.\nThis can also check strings.\n\n```ts\nimport { createRule, type Maybe } from '@regle/core';\nimport { isFilled, isDate } from '@regle/rules';\n\nconst rule = createRule({\n validator(value: Maybe<string | Date>) {\n if (isFilled(value) && isDate(value)) {\n return checkDate(value);\n }\n return true;\n },\n message: 'Error'\n})\n```\n\n## Operations utils\n\n### `getSize`\n\nThis helper will return the length of any data type you pass.\nIt works with strings, arrays, objects and numbers.\n\n```ts\nimport { createRule, type Maybe } from '@regle/core';\nimport { isFilled, getSize } from '@regle/rules';\n\nconst rule = createRule({\n validator(value: Maybe<string | Array<number>>) {\n if (isFilled(value)) {\n return getSize(value) > 6;\n }\n return true;\n },\n message: 'Error'\n})\n```\n\n### `matchRegex`\n\nThis utility can take multiple regular expressions as arguments. It checks the input's validity and tests it against the provided regex patterns.\n\n```ts\nimport { createRule, type Maybe } from '@regle/core';\nimport { isFilled, matchRegex } from '@regle/rules';\n\nconst regex = createRule({\n validator(value: Maybe<string>, regexps: RegExp[]) {\n if (isFilled(value)) {\n return matchRegex(value, ...regexps);\n }\n return true;\n },\n message: 'Error'\n})\n```\n\n## Coerce utils\n\n### `toNumber`\n\nThis utility converts any string (or number) into a number using the `Number` constructor.\n\n:::warning\nThis helper returns `NaN` if the input cannot be coerced, which is technically still a number.\n\nIt can be safe to also check for `isNaN` additionally.\n:::\n\n```ts\nimport { createRule, type Maybe } from '@regle/core';\nimport { isFilled, toNumber } from '@regle/rules';\n\nconst minValue = createRule({\n validator(value: Maybe<string | number>, min: number) {\n if (isFilled(value)) {\n const num = toNumber(value);\n return !isNaN(num) && num >= min;\n }\n return true;\n },\n message: ({ $params: [min] }) => `Value must be at least ${min}`,\n});\n```\n\n### `toDate`\n\nThis utility will coerce any string, number or Date value into a Date using the `Date` constructor.\n\n```ts\nimport { createRule, type Maybe } from '@regle/core';\nimport { isFilled, toDate } from '@regle/rules';\n\nconst afterToday = createRule({\n validator(value: Maybe<string | Date>) {\n if (isFilled(value)) {\n const date = toDate(value);\n return date > new Date();\n }\n return true;\n },\n message: 'Date must be in the future',\n});\n```"
183
+ "content": "# Validations helpers\n\nWhen writing custom rules, some checks or validations can become tedious, especially when handling values that might be null, undefined, or unset. It's also a best practice to verify whether a field is \"filled\" before proceeding with validation.\n\nTo simplify this process, Regle provides a set of utility functions to assist in creating custom rules.\n\nThese utilities can be accessed via:\n\n```ts\nimport { isFilled, isEmpty, getSize, ... } from '@regle/rules';\n```\n\n## Runtime and Type guards\n\n### `isFilled`\n\n_**Params**_\n - `value: unknown`\n - `considerEmptyArrayInvalid = true`\n\nThis is almost a must have for optional fields. It checks if any value you provided is defined (including arrays and objects).\nYou can base your validator result on this.\n\n`isFilled` also acts as a type guard.\n\nBy default, it considers empty array as `false`. You can override this behaviour with the `considerEmptyArrayInvalid`\n\n```ts\nimport { createRule } from '@regle/core';\nimport { isFilled } from '@regle/rules';\n\nconst rule = createRule({\n validator(value: unknown) {\n if (isFilled(value)) {\n return check(value);\n }\n return true;\n },\n message: 'Error'\n})\n```\n\n### `isEmpty`\n\n_**Params**_\n - `value: unknown`\n - `considerEmptyArrayInvalid = true`\n\nThis is the inverse of `isFilled`. It will check if the value is in any way empty (including arrays and objects)\n\n`isEmpty` also acts as a type guard.\n\nBy default, it considers empty array as `true`. You can override this behaviour with the `considerEmptyArrayInvalid`\n\n```ts\nimport { createRule, type Maybe } from '@regle/core';\nimport { isEmpty } from '@regle/rules';\n\nconst rule = createRule({\n validator(value: Maybe<string>) {\n if (isEmpty(value)) {\n return true;\n }\n return check(value);\n },\n message: 'Error'\n})\n```\n\n### `isNumber`\n\nThis is a type guard that will check if the passed value is a real `Number`.\nThis also returns false for `NaN`, so this is better than `typeof value === \"number\"`.\n\n```ts\nimport { createRule, type Maybe } from '@regle/core';\nimport { isFilled, isNumber } from '@regle/rules';\n\nconst rule = createRule({\n validator(value: Maybe<number | string>) {\n if (isFilled(value) && isNumber(value)) {\n return checkNumber(value);\n }\n return true;\n },\n message: 'Error'\n})\n```\n\n### `isDate`\n\nThis is a useful helper that can check if the provided value is a Date, it is used internally for `date` rules.\nThis can also check strings.\n\n```ts\nimport { createRule, type Maybe } from '@regle/core';\nimport { isFilled, isDate } from '@regle/rules';\n\nconst rule = createRule({\n validator(value: Maybe<string | Date>) {\n if (isFilled(value) && isDate(value)) {\n return checkDate(value);\n }\n return true;\n },\n message: 'Error'\n})\n```\n\n## Operations utils\n\n### `getSize`\n\nThis helper determines the size of strings, numbers, arrays, and objects.\n\n```ts\nimport { createRule, type Maybe } from '@regle/core';\nimport { isFilled, getSize } from '@regle/rules';\n\nconst rule = createRule({\n validator(value: Maybe<string | Array<number>>) {\n if (isFilled(value)) {\n return getSize(value) > 6;\n }\n return true;\n },\n message: 'Error'\n})\n```\n\n### `matchRegex`\n\nThis utility can take multiple regular expressions as arguments. It checks the input's validity and tests it against the provided regex patterns.\n\n```ts\nimport { createRule, type Maybe } from '@regle/core';\nimport { isFilled, matchRegex } from '@regle/rules';\n\nconst regex = createRule({\n validator(value: Maybe<string>, regexps: RegExp[]) {\n if (isFilled(value)) {\n return matchRegex(value, ...regexps);\n }\n return true;\n },\n message: 'Error'\n})\n```\n\n## Coerce utils\n\n### `toNumber`\n\nThis utility converts any string (or number) into a number using the `Number` constructor.\n\n:::warning\nThis helper returns `NaN` if the input cannot be coerced, which is technically still a number.\n\nIt can be safe to also check for `isNaN` additionally.\n:::\n\n```ts\nimport { createRule, type Maybe } from '@regle/core';\nimport { isFilled, toNumber } from '@regle/rules';\n\nconst minValue = createRule({\n validator(value: Maybe<string | number>, min: number) {\n if (isFilled(value)) {\n const num = toNumber(value);\n return !isNaN(num) && num >= min;\n }\n return true;\n },\n message: ({ $params: [min] }) => `Value must be at least ${min}`,\n});\n```\n\n### `toDate`\n\nThis utility will coerce any string, number or Date value into a Date using the `Date` constructor.\n\n```ts\nimport { createRule, type Maybe } from '@regle/core';\nimport { isFilled, toDate } from '@regle/rules';\n\nconst afterToday = createRule({\n validator(value: Maybe<string | Date>) {\n if (isFilled(value)) {\n const date = toDate(value);\n return date > new Date();\n }\n return true;\n },\n message: 'Date must be in the future',\n});\n```"
184
184
  },
185
185
  {
186
186
  "id": "core-concepts-validation-properties",
@@ -1050,7 +1050,7 @@ const rawData = {
1050
1050
  {
1051
1051
  "name": "exactDigits",
1052
1052
  "kind": "const",
1053
- "description": "Requires the input value to have a strict specified length. Works with arrays, objects and strings.",
1053
+ "description": "Requires the input value to have a strict specified number of digits. Works with strings and numbers.",
1054
1054
  "parameters": [{
1055
1055
  "name": "params",
1056
1056
  "type": "[count: MaybeRefOrGetter<Maybe<number>>]",
@@ -1064,14 +1064,14 @@ const rawData = {
1064
1064
  {
1065
1065
  "name": "exactLength",
1066
1066
  "kind": "const",
1067
- "description": "Requires the input value to have a strict specified length. Works with arrays, objects and strings.",
1067
+ "description": "Requires the input value to have a strict specified length. Works with arrays, objects, numbers, and strings.",
1068
1068
  "parameters": [{
1069
1069
  "name": "params",
1070
1070
  "type": "[count: MaybeRefOrGetter<Maybe<number>>]",
1071
1071
  "description": "",
1072
1072
  "optional": false
1073
1073
  }],
1074
- "returnType": "RegleRuleDefinition<\"exactLength\", string | any[] | Record<PropertyKey, any>, [count: number], false, boolean, unknown, string | any[] | Record<PropertyKey, any>, false>",
1074
+ "returnType": "RegleRuleDefinition<\"exactLength\", MeasurableValue, [count: number], false, boolean, unknown, MeasurableValue, false>",
1075
1075
  "example": "import { exactLength } from '@regle/rules';\n\nconst exactValue = ref(6);\n\nconst { r$ } = useRegle({ name: '' }, {\n name: {\n exactLength: exactLength(6),\n // or with reactive value\n exactLength: exactLength(exactValue),\n // or with getter\n exactLength: exactLength(() => exactValue.value)\n },\n})",
1076
1076
  "tags": { "see": "://reglejs.dev/core-concepts/rules/built-in-rules#exactlength Documentation" }
1077
1077
  },
@@ -1115,10 +1115,10 @@ const rawData = {
1115
1115
  {
1116
1116
  "name": "getSize",
1117
1117
  "kind": "function",
1118
- "description": "Returns the length/size of any data type. Works with strings, arrays, objects and numbers.",
1118
+ "description": "Returns the length of strings, numbers, arrays, or number of keys for objects.",
1119
1119
  "parameters": [{
1120
1120
  "name": "value",
1121
- "type": "MaybeRefOrGetter<string | number | any[] | Record<string, any>>",
1121
+ "type": "MaybeRefOrGetter<MeasurableValue>",
1122
1122
  "description": "- The value to get the size of",
1123
1123
  "optional": false
1124
1124
  }],
@@ -1333,14 +1333,14 @@ const rawData = {
1333
1333
  {
1334
1334
  "name": "maxLength",
1335
1335
  "kind": "const",
1336
- "description": "Requires the input value to have a maximum specified length, inclusive. Works with arrays, objects and strings.",
1336
+ "description": "Requires the input value to have a maximum specified length, inclusive. Works with arrays, objects, numbers, and strings.",
1337
1337
  "parameters": [{
1338
1338
  "name": "params",
1339
1339
  "type": "[max: MaybeRefOrGetter<Maybe<number>>, options?: MaybeRefOrGetter<Maybe<CommonComparisonOptions | undefined>>]",
1340
1340
  "description": "",
1341
1341
  "optional": false
1342
1342
  }],
1343
- "returnType": "RegleRuleDefinition<\"maxLength\", string | any[] | Record<PropertyKey, any>, [max: number, options?: CommonComparisonOptions | undefined], false, boolean, unknown, string | ... 1 more ... | Record<...>...",
1343
+ "returnType": "RegleRuleDefinition<\"maxLength\", MeasurableValue, [max: number, options?: CommonComparisonOptions | undefined], false, boolean, unknown, MeasurableValue, false>",
1344
1344
  "example": "import { maxLength } from '@regle/rules';\n\nconst maxValue = ref(6);\n\nconst { r$ } = useRegle({ name: '' }, {\n name: {\n maxLength: maxLength(6),\n // or with reactive value\n maxLength: maxLength(maxValue),\n // or with getter\n maxLength: maxLength(() => maxValue.value)\n },\n})",
1345
1345
  "tags": { "see": "://reglejs.dev/core-concepts/rules/built-in-rules#maxlength Documentation" }
1346
1346
  },
@@ -1375,14 +1375,14 @@ const rawData = {
1375
1375
  {
1376
1376
  "name": "minLength",
1377
1377
  "kind": "const",
1378
- "description": "Requires the input value to have a minimum specified length, inclusive. Works with arrays, objects and strings.",
1378
+ "description": "Requires the input value to have a minimum specified length, inclusive. Works with arrays, objects, numbers, and strings.",
1379
1379
  "parameters": [{
1380
1380
  "name": "params",
1381
1381
  "type": "[min: MaybeRefOrGetter<Maybe<number>>, options?: MaybeRefOrGetter<Maybe<CommonComparisonOptions | undefined>>]",
1382
1382
  "description": "",
1383
1383
  "optional": false
1384
1384
  }],
1385
- "returnType": "RegleRuleDefinition<\"minLength\", string | any[] | Record<PropertyKey, any>, [min: number, options?: CommonComparisonOptions | undefined], false, boolean, MaybeInput<...>, string | ... 1 more ... | Rec...",
1385
+ "returnType": "RegleRuleDefinition<\"minLength\", MeasurableValue, [min: number, options?: CommonComparisonOptions | undefined], false, boolean, unknown, MeasurableValue, false>",
1386
1386
  "example": "import { minLength } from '@regle/rules';\n\nconst minValue = ref(6);\n\nconst { r$ } = useRegle({ name: '' }, {\n name: {\n minLength: minLength(6),\n // or with reactive value\n minLength: minLength(minValue),\n // or with getter\n minLength: minLength(() => minValue.value)\n },\n})",
1387
1387
  "tags": { "see": "://reglejs.dev/core-concepts/rules/built-in-rules#minlength Documentation" }
1388
1388
  },
@@ -2002,7 +2002,7 @@ function searchApi(query) {
2002
2002
  });
2003
2003
  return results;
2004
2004
  }
2005
- var version = "1.23.2";
2005
+ var version = "1.24.0";
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.23.2",
3
+ "version": "1.24.0",
4
4
  "description": "MCP Server for Regle",
5
5
  "keywords": [
6
6
  "ai",