diff --git a/apps/docs/pages/schemas/array.mdx b/apps/docs/pages/schemas/array.mdx index 94c79b0..bedcdbf 100644 --- a/apps/docs/pages/schemas/array.mdx +++ b/apps/docs/pages/schemas/array.mdx @@ -24,4 +24,21 @@ try { } catch (error) { console.error('Parsing failed:', error.message); } +``` + +## Future + +In one of the next upcoming releases, the `Array` schema will support mixed schemas, so you'd be able to for example do the following: + +```ts +import { array, string, number } from '@nordic-ui/validathor'; + +const arrayRule = array([string(), number()]); + +try { + const parsedValue = arrayRule.parse(['Hello', 42, 'world']); + console.log('Parsed value:', parsedValue); +} catch (error) { + console.error('Parsing failed:', error.message); +} ``` \ No newline at end of file diff --git a/packages/validathor/src/schemas/index.ts b/packages/validathor/src/schemas/index.ts index e1e94f0..e13ff97 100644 --- a/packages/validathor/src/schemas/index.ts +++ b/packages/validathor/src/schemas/index.ts @@ -5,3 +5,4 @@ export { number } from './number' export { object } from './object' export { regex } from './regex' export { string } from './string' +export { tuple } from './tuple' diff --git a/packages/validathor/src/schemas/tuple.ts b/packages/validathor/src/schemas/tuple.ts index bef0ff4..c17a53f 100644 --- a/packages/validathor/src/schemas/tuple.ts +++ b/packages/validathor/src/schemas/tuple.ts @@ -10,7 +10,7 @@ export const tuple = []>( }, ): Parser => ({ name: 'tuple' as const, - parse: (value: unknown): T[] => { + parse: (value): T[] => { assert( Array.isArray(value), new TypeError(message?.type_error || ERROR_CODES.ERR_TYP_0000.message()),