File tree Expand file tree Collapse file tree 1 file changed +13
-13
lines changed Expand file tree Collapse file tree 1 file changed +13
-13
lines changed Original file line number Diff line number Diff line change 1- import { notEmpty } from '@ember/object/computed' ;
21import { assert } from '@ember/debug' ;
3- import RSVP from 'rsvp' ;
42import BsForm from 'ember-bootstrap/components/bs-form' ;
53
6- export default BsForm . extend ( {
7- '__ember-bootstrap_subclass' : true ,
4+ export default class BsFormWithChangesetValidationsSupport extends BsForm {
5+ '__ember-bootstrap_subclass' = true ;
86
9- hasValidator : notEmpty ( 'model.validate' ) ,
7+ get hasValidator ( ) {
8+ return typeof this . model ?. validate === 'function' ;
9+ }
1010
11- validate ( model ) {
11+ async validate ( model ) {
1212 let m = model ;
1313
1414 assert (
1515 'Model must be a Changeset instance' ,
1616 m && typeof m . validate === 'function'
1717 ) ;
18- return new RSVP . Promise ( function ( resolve , reject ) {
19- m . validate ( ) . then ( ( ) => {
20- model . get ( 'isValid' ) ? resolve ( ) : reject ( ) ;
21- } , reject ) ;
22- } ) ;
23- } ,
24- } ) ;
18+
19+ await m . validate ( ) ;
20+ if ( ! model . get ( 'isValid' ) ) {
21+ throw new Error ( ) ;
22+ }
23+ }
24+ }
You can’t perform that action at this time.
0 commit comments