Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature idea: decorator for adding validations to es6 style classes #556

Closed
danielspaniel opened this issue Dec 20, 2017 · 1 comment
Closed

Comments

@danielspaniel
Copy link
Contributor

Currently if you have your models written as es6 classes with decorators like this:

import Model from 'ember-data/model';
import { attr, belongsTo } from 'ember-decorators/data';
import Validations from '../utils/validations/message';

export default class Message extends Model { // how to add Validations to class
  @belongsTo user
  @belongsTo bookingOrder
}

you'll be hard presseed to add the Validations mixin

expect I made a decorator for this purpose that works like this

import Model from 'ember-data/model';
import { attr, belongsTo, hasMany } from 'ember-decorators/data';
import Validations from '../utils/validations/message';
import { hasValidations } from "../utils/decorators";

@hasValidations(Validations)
export default class Message extends Model {
  @belongsTo user
  @belongsTo bookingOrder

I already wrote the validator (hasValidations) , so if anyone interested I can post it

@offirgolan
Copy link
Collaborator

@danielspaniel a PR is welcome 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants