druc / intus Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
because !validation.passes()
is ugly
Can you please add typescript support to the package?
Currently the isDate()
rule only accepts Date
objects. Would be nice to work with strings as well.
Would be nice to have something like this:
"lines.*.expiration_date": [isDistinctWith(["lines.*.id"])]
This would ensure only lines with different expiration_date&id
are allowed.
Hey Constantin,
Thanks for this great library and the videos with intus was very helpfull. I have face a "problem", I have dynamics inpus and the data is in an array object. It will be a great feature if the intus support an array with data and an array with multiple rules. The intus work perfect by the way and it is great.
const validation = intus.validate({
name: [isRequired()],
products: [
products.value,
[isRequired(), ...],
],
});
I would like to report this issue where the validation.errors() produces an object key with dot notation. causing me to not access the address.province validation error.
<div class="flex flex-col">
<TextField v-model="form.address.province" label="Province" :invalidFeedback="errors.address.province" />
</div>
</div>
<script>
import { defineComponent } from 'vue';
import intus from 'intus'
import { isRequired } from 'intus/rules';
export default defineComponent({
name: 'Dashboard',
setup(){},
data(){
return {
active: false,
form: {
name: null,
address: {
province: null,
}
},
}
},
methods: {
submit(){
let validation = intus.validate(
this.form,
{
name: [isRequired()],
"address.province": [isRequired()]
},
)
if(validation.passes()){
alert('๐คก๐ฃ')
}
console.log(validation.errors())
this.errors = validation.errors()
}
},
})
</script>
<TextField v-model="form.address.barangay" label="Mokong Address" :invalidFeedback="errors ? errors['address.province'] ?? null : null " />
Am I doing something wrong or is this an expected result? Im using this work around at the moment it just breaks the intuitiveness of the package. Thank you in advance
Forgot to add "install using npm install intus
"...
Hello, there's a bug when build for production and the compiler (vite in my case) has function minification enabled.
In particular here: https://github.com/druc/intus/blob/master/lib/validation.js#L53
`${attributeToWildcard(attribute)}.${this.rules[attribute][rule].name}`
In this.rules[attribute][rule]
you have a function, and when you call Function.name
you expect to get the function name, which in case of this library means smth. You expect isRequired, isMin, etc.
But with the minification you get whatever the compiler choose for the function: ee, aa, a1.
Not really sure what the solution is for this. I guess you need a definition map for name to function in order to keep this link, as you can't really on the internal js function name.
Bogdan
subscribe @druc
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.