Security News
Bun 1.2 Released with 90% Node.js Compatibility and Built-in S3 Object Support
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
vuelidate-property-decorators
Advanced tools
A thin wrapper of vuelidate library to simplify its usage with vue-class-component.
This library provides a thin wrapper of
vuelidate
library to simplify its usage with vue-class-component
or vue-property-decorator
.
yarn add vuelidate-property-decorators
Set up vuelidate
library as described in (https://vuelidate.netlify.com/#sub-installation).
Then on your component:
To set per-field validation, use the @Validate
decorator:
import {Validate} from 'vuelidate-property-decorators';
import {required} from 'vuelidate/lib/validators'
@Component({})
export default class AddressForm extends Vue {
@Validate({required})
firstName = '';
@Validate({required})
lastName = '';
}
Template (pug in this case) looks the same way as in pure vuelidate
:
.form-group
q-input(v-model="$v.firstName.$model")
.error(v-if="!$v.firstName.required") Field is required
.form-group
q-input(v-model="$v.lastName.$model")
.error(v-if="!$v.lastName.required") Field is required
To set the validation for all fields at once, use @Validations
decorator:
import {Validations} from 'vuelidate-property-decorators';
import {required} from 'vuelidate/lib/validators'
@Component({})
export default class AddressForm extends Vue {
firstName = '';
lastName = '';
@Validations()
validations = {
firstName: {required},
lastName: {required}
}
}
Both the argument of @Validate(...)
and the value of @Validations()
can be a function that is called (reactively)
with this
set to the component instance.
Example:
import {Validate, Validations} from 'vuelidate-property-decorators';
import {required} from 'vuelidate/lib/validators'
@Component({})
export default class AddressForm extends Vue {
firstName = '';
lastName = '';
isRequired = false;
@Validations()
validations() {
if (this.isRequired) {
return {
firstName: {required},
lastName: {required}
}
}
return {}
}
@Validate(() => {
if (this.isRequired) {
return {required}
}
return {}
})
test = '';
}
FAQs
A thin wrapper of vuelidate library to simplify its usage with vue-class-component.
We found that vuelidate-property-decorators demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
Security News
Biden's executive order pushes for AI-driven cybersecurity, software supply chain transparency, and stronger protections for federal and open source systems.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.