File tree 2 files changed +21
-3
lines changed
2 files changed +21
-3
lines changed Original file line number Diff line number Diff line change @@ -1223,15 +1223,33 @@ export class Trace<
1223
1223
RelationSchemasT ,
1224
1224
VariantsT
1225
1225
> ,
1226
- ) {
1226
+ opts ?: {
1227
+ noDraftPresentBehavior : 'error' | 'warning' | 'noop'
1228
+ } ,
1229
+ ) : void {
1227
1230
const { attributes } = this . input
1228
1231
1229
1232
const { relatedTo, errors } = validateAndCoerceRelatedToAgainstSchema (
1230
1233
inputAndDefinitionModifications . relatedTo ,
1231
1234
this . definition . relationSchema ,
1232
1235
)
1233
- if ( errors . length > 0 ) {
1234
- this . traceUtilities . reportWarningFn (
1236
+
1237
+ let reportingFunction
1238
+ const { noDraftPresentBehavior } = opts ?? { }
1239
+
1240
+ switch ( noDraftPresentBehavior ) {
1241
+ case 'error' :
1242
+ reportingFunction = this . traceUtilities . reportErrorFn
1243
+ break
1244
+ case 'noop' :
1245
+ reportingFunction = undefined
1246
+ break
1247
+ default :
1248
+ reportingFunction = this . traceUtilities . reportWarningFn
1249
+ }
1250
+
1251
+ if ( errors . length > 0 && reportingFunction ) {
1252
+ reportingFunction (
1235
1253
new Error (
1236
1254
`Invalid relatedTo value: ${ JSON . stringify (
1237
1255
inputAndDefinitionModifications . relatedTo ,
You can’t perform that action at this time.
0 commit comments