@@ -27,7 +27,7 @@ function createGetterAndSetter (instance, field) {
2727}
2828
2929class Speck {
30- constructor ( data = { } ) {
30+ constructor ( data = { } , ... dependencies ) {
3131 Object . defineProperty ( this , 'schema' , {
3232 value : this . constructor . SCHEMA ,
3333 enumerable : false
@@ -44,7 +44,7 @@ class Speck {
4444 } )
4545
4646 Object . defineProperty ( this , 'data' , {
47- value : this . _mergeDefault ( data ) ,
47+ value : this . _mergeDefault ( data , ... dependencies ) ,
4848 enumerable : false
4949 } )
5050
@@ -66,14 +66,14 @@ class Speck {
6666 return isFunction ? defaultValue : clone ( this . schema [ field ] . defaultValue )
6767 }
6868
69- _mergeDefault ( data ) {
69+ _mergeDefault ( data , ... dependencies ) {
7070 const newData = { }
7171 let field
7272 for ( field in this . schema ) {
7373 newData [ field ] = this . __initFieldValue ( field , data )
7474
7575 if ( this . schema [ field ] . type || this . schema [ field ] . builder ) {
76- newData [ field ] = this . applyEntityConstructor ( this . schema [ field ] , newData [ field ] )
76+ newData [ field ] = this . applyEntityConstructor ( this . schema [ field ] , newData [ field ] , ... dependencies )
7777 }
7878
7979 Object . defineProperty ( this , field , createGetterAndSetter ( this , field ) )
@@ -132,11 +132,11 @@ class Speck {
132132 return children . reduce ( this . _includeChildErrors . bind ( this , field ) , errors )
133133 }
134134
135- applyEntityConstructor ( field , data ) {
135+ applyEntityConstructor ( field , data , ... dependencies ) {
136136 const Type = field . type
137137
138138 if ( isFunction ( field . builder ) ) {
139- return field . builder ( data , Type )
139+ return field . builder ( data , Type , ... dependencies )
140140 }
141141
142142 if ( ! data ) return
0 commit comments