Comments (7)
Hi subx, thanks for submitting an issue.
Can you give a code example of how you want to use it?
from svelte-forms-lib.
subpx/svelte-forms-lib-examples@55abfae
This is just a quick example to show the issue. The validation is working in this demo but would be much nicer to not need to manually create a fake DOM event
from svelte-forms-lib.
Thanks for the example; in this case I'll need to read up on Svelte events a bit before I can think of a solution.
However, please feel free to experiment and create a PR! I happily review it.
from svelte-forms-lib.
The most naive implementation I can think of
function isCustomEvent(event) {
return event instanceof CustomEvent;
}
function handleChange(event) {
let field;
let value;
if (isCustomEvent(event)) {
field = event.detail.name;
value = event.detail.value;
} else {
field = event.target.name;
value = event.target.value;
}
// remaining handleChange code
}
Is this something that would solve your issue?
from svelte-forms-lib.
Yep, it could be usefull.
I'm wrapping the custom event at the moment:
export function wrapCustomChangeEvent(event) {
return {
target: {
name: event.detail.name,
value: event.detail.value
}
}
}
and I'm using this function this way in the svelte component:
on:change={(event) => handleChange(wrapCustomChangeEvent(event))}
I think it's better to use a different function name maybe: handleCustomEvent?
from svelte-forms-lib.
@tjinauyeung yes that is perfect.
from svelte-forms-lib.
I'm closing this issue as updateValidateField
added by @kbytesys provides this ability to work with custom events.
from svelte-forms-lib.
Related Issues (20)
- OnChange (handleChange func) HOT 2
- Add support for Form Arrays for Helper Components
- $errors first string, then array HOT 1
- Prototype Pollution
- Document best practices for handling form submission
- View 'global' error on validationSchema's yup object
- Uncaught (in promise) TypeError: Cannot read property '$$' of null HOT 3
- Validation with nested objects behaves inconsistently HOT 1
- Is this project maintained? HOT 1
- Export FormState type
- Adding useField() functionality HOT 1
- Where can I find the documentation for v2? HOT 1
- $errors is not returning error messages for simple arrays (yup.array(yup.string().require()) HOT 1
- set errors when using helpers HOT 1
- What is the correct way to update a property in touched store that is array of objects?
- Have form.reset() HOT 2
- Manually modify initialValues HOT 1
- Add alternatives to validationSchema HOT 1
- Vite Warning: Svelte field in package.json but no export condition for svelte. HOT 1
- onSubmit Function Behaves Inappropriate
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 svelte-forms-lib.