Created
          June 14, 2018 08:47 
        
      - 
      
- 
        Save raido/5aae6e3bc81296b08073cf64fc33a235 to your computer and use it in GitHub Desktop. 
    Ember Data Validation Errors Clearing on Edit
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | import DS from 'ember-data'; | |
| import RSVP from 'rsvp'; | |
| export default DS.Adapter.extend({ | |
| createRecord(store, type, snapshot) { | |
| return RSVP.reject(new DS.InvalidError([{ | |
| title: 'my_property', | |
| detail: 'invalid_string', | |
| source: { pointer: '/data/attributes/my_property' } | |
| }])); | |
| } | |
| }); | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | import Ember from 'ember'; | |
| export default Ember.Controller.extend({ | |
| appName: 'Ember Twiddle', | |
| model: null, | |
| actions: { | |
| saveModel() { | |
| if (!this.get('model')) { | |
| this.set('model', this.store.createRecord('my-model', {})); | |
| } | |
| this.get('model').save(); | |
| } | |
| } | |
| }); | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | import Model from 'ember-data/model'; | |
| import attr from 'ember-data/attr'; | |
| import { belongsTo, hasMany } from 'ember-data/relationships'; | |
| export default Model.extend({ | |
| my_property: attr('string') | |
| }); | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | { | |
| "version": "0.14.1", | |
| "EmberENV": { | |
| "FEATURES": {} | |
| }, | |
| "options": { | |
| "use_pods": false, | |
| "enable-testing": false | |
| }, | |
| "dependencies": { | |
| "jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js", | |
| "ember": "2.18.2", | |
| "ember-template-compiler": "2.18.2", | |
| "ember-testing": "2.18.2" | |
| }, | |
| "addons": { | |
| "ember-data": "2.18.2" | |
| } | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment