Security News
38% of CISOs Fear They’re Not Moving Fast Enough on AI
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
@treacherous/vue
Advanced tools
It is a validation plugin for Vue that lets you validate on data, props, computed properties within your components.
VIEW THE EXAMPLE/DEMO HERE
This is the Vue wrapper for Treacherous, which is slightly different in usage than the knockout and aurelia ones as it follows existing paradigms set by vues existing validation libraries.
It is worth reading over the Treacherous libraries if you want to do more than basic validation scenarios, they can be found:
To use treacherous in vue you will need to install this module:
npm install @treacherous/vue
Then register the plugin with vue:
import Vue from "vue";
import TreacherousPlugin from "@treacherous/vue";
myApp.use(TreacherousPlugin);
Once you have done this you can use the ValidateWith(ruleset, options?)
mixin.
if you are living in the era before modules just grab the UMD module which adds you the TreacherousVue
object, and you would do Vue.use(TreacherousVue.default);
.
You will still need to include the treacherous UMD module which will provide Treacherous
global for use.
import {createRuleset, ValidateWith} from "@treacherous/vue";
const ruleset = createRuleset()
.forProperty("name")
.addRule("required")
.build();
myApp.component('my-component', {
data: function() {
name: "Bob"
},
template: '<input id="name" v-model="name" v-show-error validate-property="name" />',
mixins: [ ValidateWith(ruleset) ]
});
So as seen above you can optionally provide for any component a ruleset
property, which if used will pick up what rules you want to apply to the data
contained within the component.
When you register the mixin you get:
modelErrors
data object, which is kept up to date by the validation systemisValid
computed, which monitors the modelErrors and gives a high level true/false accessormodel-state-changed
event, which is raised whenever the validation state changes (passes out { isValid, modelErrors }
getValidationGroup()
method, which gets the underlying validation grouprefreshValidation()
method, which manually refreshes the underlying validation statewithReactiveValidation: boolean
makes the view react to validation changes without you progmatically validatingvalidateOnStart: boolean
validates the model when the component is created and shows errors up front, rather than waiting for changes/progmatic validation callsvalidateProps: boolean
enables validation of props
fields (by default only data
fields are used)validateComputed: boolean
enables validation of computed
fields (by default only data
fields are used)v-show-error
this tells the element to display errors for validation elements (required you to set target property via validate-property="some-data-property"
)v-validation-summary
this should be passed the validation group/s you want to output a summary forSee examples for use cases on both of these directives.
There are docs on each subject within the docs folder, its worth reading them and viewing the example to see how to use the framework and how to make use of treacherous features.
VIEW THE DOCS HERE
VIEW THE EXAMPLE/DEMO HERE
"Mountains" Icon courtesy of The Noun Project, by Aleksandr Vector, under CC 3.0
"Vue" Icon courtesy of vue.js project
FAQs
A vue plugin to use the treacherous validation system
The npm package @treacherous/vue receives a total of 1 weekly downloads. As such, @treacherous/vue popularity was classified as not popular.
We found that @treacherous/vue 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
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.
Security News
Company News
Socket is joining TC54 to help develop standards for software supply chain security, contributing to the evolution of SBOMs, CycloneDX, and Package URL specifications.