Skip to content

Instantly share code, notes, and snippets.

@hakant
Created April 5, 2016 18:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hakant/69363eaf32e2052d2d2697335704555e to your computer and use it in GitHub Desktop.
Save hakant/69363eaf32e2052d2d2697335704555e to your computer and use it in GitHub Desktop.
import {computedFrom} from 'aurelia-framework';
import {Container} from 'aurelia-dependency-injection';
import {ensure} from 'aurelia-validation';
import {Validation} from 'aurelia-validation';
export class Project {
@ensure(function(it) { it.isNotEmpty().hasLengthBetween(3, 100) })
_title = null;
@ensure(function(it) { it.isNotEmpty().hasLengthBetween(5, 300) })
_overview = null;
constructor(data) {
this._id = data.id;
this._user = data.user;
this._title = data.title;
this._overview = data.overview;
let validation = Container.instance.get(Validation);
this.validation = validation.on(this);
this._data = data;
}
@computedFrom('_likeCount')
get likeCount() {
return this._likeCount;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment