Comments (3)
It seems that validation is only triggered when all fields are dirty.
Unfortunately, that's too late and you could submit an invalid form with empty but required fields.
from svelte-forms.
Big bug actually. I really don't know how about anyone didn't care about it.
Not a fix, but a good workaround is:
import { onMount } from "svelte";
onMount(() => { myForm.validate() })
This makes the Form work properly.
from svelte-forms.
Add { checkOnInit: true }
as the last argument to any of the fields used in the form:
export const name = field('name', '', [required()], {
checkOnInit: true
})
export const accountForm = form(name)
from svelte-forms.
Related Issues (20)
- [REQUEST] addField() method HOT 2
- [BUG] min validation evaluates string as number HOT 2
- [REQUEST] Be able to loop through all a field's errors
- [BUG] $myForm.hasError('email.email') not functional HOT 1
- Error names without period are not detected in hasError
- [REQUEST] Enable new defaults after submit HOT 1
- [BUG] validateOnChange prevents fields from being marked as dirty
- [BUG]: min() function doesn't work with a string of numbers only HOT 1
- [BUG] Combined function marks dirty attribute as true HOT 1
- [BUG] email validator doesn't return a form error HOT 1
- [BUG] min validator for strings not consistent HOT 2
- [BUG] matchField does not re-evaluate when the other field is changed
- [REQUEST] eitherOr validator
- [REQUEST] optional validator HOT 2
- How to handle array data type? HOT 1
- Keep input value on HRM
- How to modify input value before valiationOnChange? HOT 1
- Using in Astro HOT 1
- [ANNOUNCEMENT] Getting back working on svelte-forms and looking for maintainers! HOT 9
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.