File tree Expand file tree Collapse file tree 3 files changed +11
-11
lines changed Expand file tree Collapse file tree 3 files changed +11
-11
lines changed Original file line number Diff line number Diff line change @@ -49,7 +49,7 @@ export declare class InMemoryEntity {
4949 * @summary Clone this entity
5050 */
5151 clone ( extraContext ?: object ) : this;
52- static validateData ( data : AnyObject , clean ?: boolean ) : AnyObject ;
52+ static validateData ( data : AnyObject , clean ?: boolean , jsonSchema ?: import ( "json-schema" ) . JSONSchema7 | undefined ) : AnyObject ;
5353 /**
5454 * @summary Validate entity contents against schema
5555 */
Original file line number Diff line number Diff line change @@ -105,22 +105,22 @@ class InMemoryEntity {
105105 ...extraContext ,
106106 } ) ;
107107 }
108- static validateData ( data , clean = false ) {
109- if ( ! this . jsonSchema ) {
108+ static validateData ( data , clean = false , jsonSchema = this . jsonSchema ) {
109+ if ( ! jsonSchema ) {
110110 return data ;
111111 }
112112 const result = clean
113- ? ajv . validateAndClean ( data , this . jsonSchema , {
113+ ? ajv . validateAndClean ( data , jsonSchema , {
114114 coerceTypes : this . allowJsonSchemaTypesCoercing ,
115115 } )
116- : ajv . validate ( data , this . jsonSchema ) ;
116+ : ajv . validate ( data , jsonSchema ) ;
117117 if ( ! result . isValid ) {
118118 throw new EntityError ( {
119119 code : ValidationErrorCode . IN_MEMORY_ENTITY_DATA_INVALID ,
120120 details : {
121121 error : result === null || result === void 0 ? void 0 : result . errors ,
122122 json : data ,
123- schema : this . jsonSchema ,
123+ schema : jsonSchema ,
124124 } ,
125125 } ) ;
126126 }
Original file line number Diff line number Diff line change @@ -116,23 +116,23 @@ export class InMemoryEntity {
116116 } ) ;
117117 }
118118
119- static validateData ( data : AnyObject , clean = false ) {
120- if ( ! this . jsonSchema ) {
119+ static validateData ( data : AnyObject , clean = false , jsonSchema = this . jsonSchema ) {
120+ if ( ! jsonSchema ) {
121121 return data ;
122122 }
123123 const result = clean
124- ? ajv . validateAndClean ( data , this . jsonSchema , {
124+ ? ajv . validateAndClean ( data , jsonSchema , {
125125 coerceTypes : this . allowJsonSchemaTypesCoercing ,
126126 } )
127- : ajv . validate ( data , this . jsonSchema ) ;
127+ : ajv . validate ( data , jsonSchema ) ;
128128
129129 if ( ! result . isValid ) {
130130 throw new EntityError ( {
131131 code : ValidationErrorCode . IN_MEMORY_ENTITY_DATA_INVALID ,
132132 details : {
133133 error : result ?. errors ,
134134 json : data ,
135- schema : this . jsonSchema ,
135+ schema : jsonSchema ,
136136 } ,
137137 } ) ;
138138 }
You can’t perform that action at this time.
0 commit comments