[Snyk] Upgrade @vinejs/vine from 2.0.0 to 2.1.0 #6
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR was automatically created by Snyk using the credentials of a real user.
![snyk-top-banner](https://github.com/andygongea/OWASP-Benchmark/assets/818805/c518c423-16fe-447e-b67f-ad5a49b5d123)
Snyk has created this PR to upgrade @vinejs/vine from 2.0.0 to 2.1.0.
ℹ️ Keep your dependencies up-to-date. This makes it easier to fix existing vulnerabilities and to more quickly identify and fix newly disclosed vulnerabilities when they affect your project.
The recommended version is 1 version ahead of your current version.
The recommended version was released on a month ago.
Release notes
Package name: @vinejs/vine
tryValidate
The
tryValidate
method can be used to perform validation without throwing a validation error. Instead, the errors are returned as the return value of the method, which is a tuple.The
try
prefix is inspired from the Java world.in
The
in
validation rule has been added for theVineNumber
schema type and can be used to ensure the value of field is part of the allowed values list.toJSON
The
validator.toJSON
method can be used to get the validator and its refs as JSON.Commits
What's Changed
New Contributors
Full Changelog: v2.0.0...v2.1.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
categories: vine.array(vine.number()),
})
const data = {
categories: [1, 'foo', 'bar', 11],
}
The errors reported up until 2.0 were
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 theindex
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 theindex
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
.Infer Schema Input value ( Breaking )
After this release, you can infer the input values a Schema type accepts. Let's consider the following example.
const schema = vine.object({
is_admin: vine.boolean()
})
InferInput<typeof Schema>
{
is_admin: boolean | string | number
}
If you notice, the
is_admin
property accepts aboolean | string | number
. VineJS is built for parsing form inputs submitted over HTTP. Therefore, it receives all inputs asstring
values and performs normalization before performing any sort of validation.Because of this change, the
BaseSchema
classes accept another generic value for theInputTypes
. 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. df27df8
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:
Commits
What's Changed
New Contributors
Full Changelog: v1.7.0...v2.0.0
Important
Note: You are seeing this because you or someone else with access to this repository has authorized Snyk to open upgrade PRs.
For more information: