You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is submitted as a bug, but might as well be a documentation issue or feature request, depending how one looks at it.
My issue lies with vine.object, primarily the behaviour when one uses it as follows:
vine.object()// instead of:vine.object({})
This will generate the following error: TypeError: Cannot convert undefined or null to object, with a stacktrace that does not really help. The problem comes down to vine.object expecting an object as parameter. Developers using plain JS will have a hard time figuring this out, as the documentation isn't that clear on this either, note the word may:
Ensure the value of a field is a valid JavaScript object literal.
You __may__ define a collection of properties you want to validate within the object.
What should it do?
I believe there are several routes that could be picked, that are not mutually exclusive:
Implement a runtime check if an object is provided, and throw a clearer error if there is not
Give vine.object a default parameter ({})
Update the docs, stating that one must provide an object
Or even, allow vine.object() to work, just validating that something is an object (with/without allowUnknownProperties)
Reproduction repo
No response
The text was updated successfully, but these errors were encountered:
Oftentimes, there won't be. For me, the issue arose when I did not want to validate the contents of an object exported from a WYSIWYG editor (like tiptap or editorjs). I wanted vine to validate that an object was present, but skip checking the exact contents of it.
This is perfectly possible at the moment, but only with vine.object({}).allowUnknownProperties(). To me this feels cumbersome and inconsistent with the rest of the API. However, my main problem is the vagueness of the error.
Package version
1.6.0
Describe the bug
My issue lies with
vine.object
, primarily the behaviour when one uses it as follows:This will generate the following error:
TypeError: Cannot convert undefined or null to object
, with a stacktrace that does not really help. The problem comes down tovine.object
expecting an object as parameter. Developers using plain JS will have a hard time figuring this out, as the documentation isn't that clear on this either, note the wordmay
:What should it do?
I believe there are several routes that could be picked, that are not mutually exclusive:
vine.object
a default parameter ({}
)vine.object()
to work, just validating that something is an object (with/withoutallowUnknownProperties
)Reproduction repo
No response
The text was updated successfully, but these errors were encountered: