Comments (1)
Hi @datasc123
Ember model validator is going to add the errors to the ember model, but you have to print them in your template.
So, in order to do that you have to add a button which call a function in your route
or controller
and that function have to do something like the function in the README:
import Ember from 'ember';
export default Ember.Route.extend(
{
actions: {
saveFakeModel: function() {
var _this = this,
fakeModel = this.get('model');
if(fakeModel.validate()){
fakeModel.save().then(
// Success
function() {
// Alert success
console.log('ooooh yeah we just saved the FakeModel...');
},
// Error handling
function(error) {
// Alert failure
console.log('There was a problem saving the FakeModel...');
console.log(error);
}
);
}else{
fakeModel.get('errors');
}
},
}
}
);
In that example, the validate()
method is going to add errors to the fakeModel
, but, in order to show the errors you have to use the errors
attr of the fakeModel
in the template.
You have many options to print the errors in your template. The most basic way to do it is documented here: http://emberjs.com/api/data/classes/DS.Errors.html
Example from the document:
ADDITIONAL COMMENT
I don't know how you are setting the model in your template, but it looks wrong in the example you shared. Could you share the route.js for that template?
Regards,
Daniel.
from ember-model-validator.
Related Issues (20)
- An in-range update of ember-cli-htmlbars is breaking the build 🚨 HOT 1
- An in-range update of ember-cli-inject-live-reload is breaking the build 🚨 HOT 2
- An in-range update of sass is breaking the build 🚨 HOT 10
- An in-range update of ember-ajax is breaking the build 🚨 HOT 1
- An in-range update of eslint-plugin-ember is breaking the build 🚨 HOT 2
- An in-range update of ember-template-lint is breaking the build 🚨 HOT 12
- An in-range update of ember-cli-htmlbars-inline-precompile is breaking the build 🚨 HOT 1
- An in-range update of ember-cli-babel is breaking the build 🚨 HOT 9
- An in-range update of ember-cli is breaking the build 🚨 HOT 2
- An in-range update of ember-cli-htmlbars is breaking the build 🚨 HOT 1
- When do you plan to make next release? HOT 2
- `errors` is a proxy object with no length HOT 2
- model.validate() causes error HOT 6
- ember-global deprecation warning on 3.28 HOT 2
- Potential Feature: Validate from template function HOT 1
- InternalModel removed in ember 4.6 HOT 1
- not validate octane relations HOT 1
- Error with [email protected] and ember 4.6+ HOT 1
- Error with ember model fragment while validating with ember-model-validator
- Add support to validate nested objects
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-model-validator.