A Vue composable that offers methods to access the validation error bag in the template
npm install @elieandraos/clockwork-vue!GitHub Workflow Status


!npms.io (quality)
!downloads
!NPM
This package ships a Vue 3 composable that exposes the clockwork error bag to the component template.
All the validation is still handled by the clockwork library, so make sure to check
the full documentation to benefit from all its
features (built-in rules, custom rules, etc...)
shell
npm install @elieandraos/clockwork @elieandraos/clockwork-vue --save
`Usage
The composable adds a reactive variable $errors to the component state.
It should be filled with the clockwork error bag when the validation fails.It also exposes 3 methods to the component template
-
getErrors(key=null) _return all the error messages or all the error messages of key if specified_
- getFirstError(key=null) _return the first error message found or the first error message of key if specified_
- hasErrors(key=null) _checks if there is any validation error or any validation error for the key if specified_`vue
`Full example with the clockwork library
`vue
{{ getFirstError('name') }}
{{ getFirstError('email') }}
``