Skip to content

Commit

Permalink
feat: validator state value check
Browse files Browse the repository at this point in the history
  • Loading branch information
jeanvier committed Sep 25, 2024
1 parent b51589b commit b416ffe
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@wgr-sa/nuxt-form",
"description": "Form builder for Nuxt",
"version": "0.8.6",
"version": "0.8.8",
"repository": "https://github.com/WGR-SA/nuxt-form.git",
"author": "jeanvier",
"license": "MIT",
Expand Down
13 changes: 8 additions & 5 deletions src/runtime/composables/validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,15 @@ export const useFormValidator = () => {
return
}

// @ts-ignore TODO: import only validation functions
const result = validator(form.data.state[field].toString(), rule.$params.options)

if (!result && (form.data.state[field].length > 0 && form.data.state[field] !== 'false' || ['error', 'validate'].includes(form.state.status))) {
errors.value.push(rule.custom_message ?? rule.$message)
if (form.data.state[field]) {
// @ts-ignore TODO: import only validation functions
const result = validator(form.data.state[field].toString(), rule.$params.options)

if (!result && (form.data.state[field].length > 0 && form.data.state[field] !== 'false' || ['error', 'validate'].includes(form.state.status))) {
errors.value.push(rule.custom_message ?? rule.$message)
}
}

})

return errors.value
Expand Down

0 comments on commit b416ffe

Please sign in to comment.