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' ;
2
1
import { assert } from '@ember/debug' ;
3
- import RSVP from 'rsvp' ;
4
2
import BsForm from 'ember-bootstrap/components/bs-form' ;
5
3
6
- export default BsForm . extend ( {
7
- '__ember-bootstrap_subclass' : true ,
4
+ export default class BsFormWithChangesetValidationsSupport extends BsForm {
5
+ '__ember-bootstrap_subclass' = true ;
8
6
9
- hasValidator : notEmpty ( 'model.validate' ) ,
7
+ get hasValidator ( ) {
8
+ return typeof this . model ?. validate === 'function' ;
9
+ }
10
10
11
- validate ( model ) {
11
+ async validate ( model ) {
12
12
let m = model ;
13
13
14
14
assert (
15
15
'Model must be a Changeset instance' ,
16
16
m && typeof m . validate === 'function'
17
17
) ;
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