File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11'use strict' ;
22
33const Axios = require ( 'axios' ) ;
4- const Joi = require ( 'joi-browser ' ) ;
4+ const Joi = require ( 'joi' ) ;
55const Utils = require ( './utils' ) ;
66
77const internals = { } ;
@@ -55,12 +55,15 @@ class Model {
5555 if ( typeof descriptor === 'undefined' || typeof descriptor . set === 'undefined' ) {
5656 gettersAndSetters . set = function ( val ) {
5757
58- const result = Joi . validate ( val , this . constructor . properties [ key ] . label ( key ) ) ;
59- if ( result . error ) {
60- throw result . error ;
58+ let value ;
59+ try {
60+ value = Joi . assert ( val , this . constructor . properties [ key ] . label ( key ) ) ;
61+ }
62+ catch ( error ) {
63+ throw error ;
6164 }
6265
63- this . attrs [ key ] = result . value ;
66+ this . attrs [ key ] = value ;
6467 } ;
6568 }
6669 else {
@@ -143,7 +146,6 @@ class Model {
143146 */
144147 parse ( response ) {
145148
146- console . log ( 'Response data' , response . data ) ;
147149 return response . data ;
148150 }
149151
Original file line number Diff line number Diff line change 11{
22 "name" : " perse-model" ,
33 "description" : " Browser REST models" ,
4- "version" : " 0.0.2 " ,
4+ "version" : " 0.1.0 " ,
55 "repository" : {
66 "type" : " git" ,
77 "url" : " git://github.com/sauramirez/perse-model"
1313 "author" : " Essau Ramirez" ,
1414 "license" : " MIT" ,
1515 "dependencies" : {
16- "axios" : " ^0.18.0 " ,
17- "joi-browser " : " ^13.4 .0" ,
18- "qs" : " ^6.5.2 "
16+ "axios" : " ^0.21.1 " ,
17+ "joi" : " ^17.3 .0" ,
18+ "qs" : " ^6.9.6 "
1919 }
2020}
You can’t perform that action at this time.
0 commit comments