Comments (9)
@poteto The validation that is proposed works nice but it expects you to define changeset outside of templates. When (changeset data validation) is used I'm not able to find a way how to do it and I have to modify your module.
It is enough to extend function changeset([model, validationMap]) with changset.validate(). This should be configurable, so adding a new attribute (e.g. initValidation with false as a default) looks sensible. If I will prepare PR, are you willing to merge it?
from ember-changeset-validations.
Could you call validate
on the init of whatever it is that's being instantiated, like in your snippet above?
from ember-changeset-validations.
@poteto For sure, but it does limit building validated changesets in a template. Should this be a default behaviour in your mind? Perhaps an option that can be passed to the constructor?
from ember-changeset-validations.
@marxsk That's what I ultimately ended up doing and just setting a controller or component property for the template to bind to the pre-validated changeset object.
from ember-changeset-validations.
@poteto could we bump this issue ? This is badly needed.
I have the same issue and using validate()
right after the Changeset has been initialised is not the proper solution I think.
For instance, by doing that it forces all the error messages to show up on the first render of a form.
from ember-changeset-validations.
@MrChocolatine I often use the suggested pattern with much success. I call validate()
right after initializing the Changeset, but then I hide validation errors in the form until other events occur such as an individual input blur (show errors for that field) or the user tries to submit the form (show errors for all fields). I really like the flexibility and control that this approach gives me.
from ember-changeset-validations.
To me it sounds more like an incorrect implementation. We should not to have to do this manually and a first validation should occur internally, when the Changeset is created. Or at least via an option as already suggested.
from ember-changeset-validations.
@MrChocolatine Appreciate the input! I certainly think an optional initValidation boolean approach is worthwhile and will help give users visibility into the initial state of the changeset without hooking into the JS side of things. I generally wait until user input to perform any of this logic (submit/blur) but I can see that limited use cases may require this API. I created an issue in ember-changeset to track and implement.
from ember-changeset-validations.
Thank you @snewcomer 👍 .
from ember-changeset-validations.
Related Issues (20)
- async validator is called multiple times with the same value HOT 2
- Date validator does not respect 'rawOutput' option HOT 2
- async validators can complete out of order HOT 4
- Documentation for rawOutput
- (Octane) skipValidate=true in helper does not work HOT 2
- (Octane) Documentation update suggestion: passing the validation instance HOT 1
- ember inspector silently polluting `changes`? HOT 1
- Button attribute not updating using classic components syntax HOT 1
- Access Service from validator class
- Freezed value in Input HOT 5
- Update to ember-validates v4 is breaking change HOT 2
- allowBlank doesn't work with validateFormat() HOT 1
- [Proposal] Use isEmpty for the date validator's allowBlank alike the other validators
- Use of `assign` has been deprecated
- [rfc]: Externalize schema validation HOT 4
- Strange behavior with an array of objects HOT 2
- Dependent field validation capability
- Docs pages are missing
- `description` option type missing for validators
- Provided description for validation not passed in rawOutput for buildMessage
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 ember-changeset-validations.