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
IDE tell me that Property 'key' does not exist on type 'IssuePathItem'.. But when I log it it gives me the expected value.(in this case "message")
Here is the snippet
functionvalidate(){constschema=v.object({name: v.pipe(v.string(),v.nonEmpty('Name is required')),email: v.pipe(v.string(),v.trim(),v.email('Invalid Email')),message: v.custom(input=>typeofinput==='string'&&input.split(' ').length>5,'Please write a bit more so I can understand you better!'),})constname=nameInput!.value??''constemail=emailInput!.value??''constmessage=messageInput!.value??''constresult=v.safeParse(schema,{ name, email, message })console.log(result)if(!result.success){result.issues.map(issue=>{console.log(issue.path![0].key)// 'message'if(issue.path&&issue.path[0].key==='message'){// here it give me the error for .key// show message}})}returntrue}
The text was updated successfully, but these errors were encountered:
This is because not every path item has a .key property, but I plan to improve the developer experience on this part by adding key: undefined in this case. There is a workaround to fix the TS error. Here is an example:
if(issue.path&&'key'inissue.path![0]&&issue.path![0].key==='message'){// show message}
Tip: You can also pass the issue to v.getDotPath(issue) to get its path.
IDE tell me that
Property 'key' does not exist on type 'IssuePathItem'.
. But when I log it it gives me the expected value.(in this case "message")Here is the snippet
The text was updated successfully, but these errors were encountered: