Comments (5)
Ahhh! I hadn't considered that aspect of the $ prefix. Removing the prefix would prevent you from having property names of invalid, errors, messages, pending, etc. I don't think I've ever had data property names that need to be validated with any of those names, but if you make that a requirement it's guaranteed someone will.
So for the Entry
and Result
types leaving those $ prefixes in place makes sense. For Rule
though there aren't any additional properties so the $ could be removed there.
from vue-tiny-validate.
Sorry! Was editing my comment as you closed it.
from vue-tiny-validate.
No worries 😅. I do agree that the $ prefix in Rule
need to be removed. And the$key
should be renamed to name
. 👍
from vue-tiny-validate.
Hi SharpSeeEr. Thank you for your suggestions.
The reason why I put the $ prefix in property names of Entry and Result is to differentiate these properties with data properties.
Lets take a look at the example below
const data = reactive({
test: false,
invalid: false
})
const rule = reactive({
test: { $test: value => Boolean(value), $key: 'bool' },
invalid: { $test: value => Boolean(value), $key: 'bool' },
})
const { result } = useValidate(data, rule)
And then the result
object will be
{
$invalid: false;
$errors: [];
$messages: [];
$pending: false;
$test: () => void;
$reset: () => void;
$touch: () => void;
test: {
$invalid: false;
$errors: [];
$messages: [];
$pending: false;
$test: () => void;
$reset: () => void;
$touch: () => void;
},
invalid: {
$invalid: false;
$errors: [];
$messages: [];
$pending: false;
$test: () => void;
$reset: () => void;
$touch: () => void;
}
}
As you can see, if I remove the $ prefix, the test
method will be replace by the test property. That's not what I want.
Removing $ in the Rule is not a big deal. I'm ok with that thing. However, why I still keep it is because I want to keep property names pattern consistent between objects.
Currently, I haven't found any solution for this problem. So, any ideas?
from vue-tiny-validate.
Updated #6
from vue-tiny-validate.
Related Issues (8)
- how to use with options api HOT 2
- Resolve conflict with nuxt ^3.0.0 HOT 1
- Validate array of objects HOT 1
- Pass a second parameter to the test function containing the root state HOT 2
- Rename the Rule types "$key" property to "name" to match Error.name HOT 1
- Support for @vue/composition-api HOT 4
- Documentation issue HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vue-tiny-validate.