Skip to content

Instantly share code, notes, and snippets.

@Sinled
Created September 6, 2016 15:57
Show Gist options
  • Save Sinled/f36e6ab402def95ca8461ac25019d5ec to your computer and use it in GitHub Desktop.
Save Sinled/f36e6ab402def95ca8461ac25019d5ec to your computer and use it in GitHub Desktop.
ember-cp-validations-test-empty-buildValidations
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
import Ember from 'ember';
import Model from "ember-data/model";
import attr from "ember-data/attr";
import { belongsTo, hasMany } from "ember-data/relationships";
import { buildValidations } from 'ember-cp-validations';
// Redefine tms-admin-core default validations
export const Validations = buildValidations({});
export default Model.extend(Validations, {
isMyModelValid: Ember.computed('validations.isInvalid', function() {
return this.get('validations.isInvalid');
}),
});
import Ember from 'ember';
export default Ember.Route.extend({
model() {
return this.store.createRecord('my-model');
}
});
<h1>Welcome to {{appName}}</h1>
<br>
Is Model Valid: {{model.isMyModelValid}}
<hr>
<br>
{{outlet}}
<br>
<br>
{
"version": "0.10.4",
"EmberENV": {
"FEATURES": {}
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "2.7.0",
"ember-data": "2.7.0",
"ember-template-compiler": "2.7.0",
"ember-cp-validations": "2.9.5"
},
"addons": {
"ember-cp-validations": "2.9.5"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment