Permalink
Browse files

feat(validator): Added validation rule for associations

  • Loading branch information...
RWOverdijk committed Dec 21, 2015
1 parent 2f32baf commit 350c9e31570e616035b0e52a43b57d226c4fbd8f
Showing with 13 additions and 0 deletions.
  1. +13 −0 src/validator/has-association.js
@@ -0,0 +1,13 @@
import {ValidationRule} from 'aurelia-validation';
import {Entity} from '../index';
export class HasAssociationValidationRule extends ValidationRule {
constructor() {
super(
null,
value => !!((value instanceof Entity && typeof value.id === 'number') || typeof value === 'number'),
null,
'isRequired'
);
}
}

0 comments on commit 350c9e3

Please sign in to comment.