stacksjs / stacks

⚛️ Type-safe full-stack framework for Artisans. Develop modern clouds, apps & framework-agnostic libraries, faster.
https://stacksjs.org
MIT License
522 stars 9 forks source link

chore(deps): update peerdependency @vinejs/vine to v2 #986

Closed renovate[bot] closed 6 months ago

renovate[bot] commented 6 months ago

Mend Renovate

This PR contains the following updates:

Package Change Age Adoption Passing Confidence
@vinejs/vine ^1.8.0 -> ^2.0.0 age adoption passing confidence

Release Notes

vinejs/vine (@​vinejs/vine) ### [`v2.0.0`](https://togithub.com/vinejs/vine/releases/tag/v2.0.0): Improved error reporting for fields inside arrays and infer schema input types [Compare Source](https://togithub.com/vinejs/vine/compare/v1.8.0...v2.0.0) This release contains a couple of minor breaking changes. So let's first talk about them. ##### Improved error reporting for fields inside arrays ( Breaking ) In the previous versions of VineJS, the error reporting for fields inside arrays could have been better. Given the following schema and data ```ts const schema = vine.object({ categories: vine.array(vine.number()), }) const data = { categories: [1, 'foo', 'bar', 11], } ``` The errors reported up until 2.0 were ```ts { field: 'categories.*', index: 1, message: 'The 1 field must be a number', rule: 'number', }, { field: 'categories.*', index: 2, message: 'The 2 field must be a number', rule: 'number', } ``` If you notice, the field name inside arrays is defined as `categories.*` and not the actual index of the item inside the array. Now, you may think that I can replace the `*` with the `index` property value and get a nested path to the item index within the array. Well, the replacement of `*` might work in this situation. But it will not work when there are errors inside nested arrays or the field that failed the validation is a grandchild of an array. Because the `index` property only exists when the field is an immediate child of an array. But anyway, after this release, you do not have to perform any manual substitutions. The field names are nested paths with the correct index. The following is an example of errors with `@vinejs/vine@2`. ```ts { field: 'categories.1', index: 1, message: 'The 1 field must be a number', rule: 'number', }, { field: 'categories.2', index: 2, message: 'The 2 field must be a number', rule: 'number', } ``` ##### Infer Schema Input value ( Breaking ) After this release, you can infer the input values a Schema type accepts. Let's consider the following example. ```ts import { InferInput } from '@​vinejs/vine/types' const schema = vine.object({ is_admin: vine.boolean() }) InferInput { is_admin: boolean | string | number } ``` If you notice, the `is_admin` property accepts a `boolean | string | number`. VineJS is built for parsing form inputs submitted over HTTP. Therefore, it receives all inputs as `string` values and performs normalization before performing any sort of validation. Because of this change, the `BaseSchema` classes accept another generic value for the `InputTypes`. So, if you use the BaseSchema anywhere in your apps, make sure to pass the Input type as the first generic argument. Also, please consult this commit for a better understanding of the change. https://github.com/vinejs/vine/commit/df27df8314e019f6cf22619e46dfbbebe2a41737 ##### Define error messages for specific array index or a wildcard ( New feature ) Now, you will be able to define custom error messages for specific array indexes with a wildcard fallback for rest of the indexes. For example: ```ts { "contacts.0.email.required": "The primary email address is required", "contacts.*.email.required": "The email address is required", } ``` ##### Commits - style: remove unused type [`9dd733c`](https://togithub.com/vinejs/vine/commit/9dd733c) - feat: add support for inferring schema input types [`df27df8`](https://togithub.com/vinejs/vine/commit/df27df8) - feat: improve error reporting for fields inside arrays [`3d59dad`](https://togithub.com/vinejs/vine/commit/3d59dad) - chore: update dependencies [`8ff246f`](https://togithub.com/vinejs/vine/commit/8ff246f) ##### What's Changed - refactor: dynamic import node:dns by [@​Julien-R44](https://togithub.com/Julien-R44) in [https://github.com/vinejs/vine/pull/24](https://togithub.com/vinejs/vine/pull/24) - Add Valibot to benchmarks by [@​nakrovati](https://togithub.com/nakrovati) in [https://github.com/vinejs/vine/pull/33](https://togithub.com/vinejs/vine/pull/33) - Fix lolo32 PR by [@​nakrovati](https://togithub.com/nakrovati) in [https://github.com/vinejs/vine/pull/39](https://togithub.com/vinejs/vine/pull/39) - Fix typo in Symbol(schema_nme) by [@​Izurii](https://togithub.com/Izurii) in [https://github.com/vinejs/vine/pull/36](https://togithub.com/vinejs/vine/pull/36) - docs: update benchmarks by [@​nakrovati](https://togithub.com/nakrovati) in [https://github.com/vinejs/vine/pull/40](https://togithub.com/vinejs/vine/pull/40) - feat: implement requiredIf rules by [@​thetutlage](https://togithub.com/thetutlage) in [https://github.com/vinejs/vine/pull/42](https://togithub.com/vinejs/vine/pull/42) ##### New Contributors - [@​nakrovati](https://togithub.com/nakrovati) made their first contribution in [https://github.com/vinejs/vine/pull/33](https://togithub.com/vinejs/vine/pull/33) - [@​Izurii](https://togithub.com/Izurii) made their first contribution in [https://github.com/vinejs/vine/pull/36](https://togithub.com/vinejs/vine/pull/36) **Full Changelog**: https://github.com/vinejs/vine/compare/v1.7.0...v2.0.0

Configuration

📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 Ignore: Close this PR and you won't be reminded about these updates again.



This PR has been generated by Mend Renovate. View repository job log here.