Open paulwer opened 2 weeks ago
Visit the deploys page to approve it
Name | Link |
---|---|
Latest commit | d9c952cd39587a2301b23cea6787555b6e4c698f |
@rifont is it possible to include this in Release 2.4.0
Hey @paulwer , we still need to address the comments from here regarding polymorphism, this is the last blocker to release. Would it be possible for you to take a look at those?
i could resolve them tomorrow morning, if that fits your schedule.
when trying to use a discriminated union type an error occurs because class-validator-jsonschema cannot directly infer a discriminated union type using decorators like @Type inside the union classes. Since class-validator-jsonschema doesn’t fully support conditional @Type decorators.
the following is therefore not possible to implement:
class StringType {
@IsIn(['stringType'])
type!: 'stringType';
@IsString()
stringVal!: string;
}
class NumberType {
@IsIn(['numberType'])
type!: 'numberType';
@IsNumber()
numVal!: number;
}
class BooleanType {
@IsIn(['booleanType'])
type!: 'booleanType';
@IsBoolean()
boolVal!: boolean;
}
class DiscriminatedUnionType {
@IsIn(['stringType', 'numberType', 'booleanType'])
type!: 'stringType' | 'numberType' | 'booleanType';
@ValidateNested()
@Type((obj) => {
switch (obj?.object.type) {
case 'stringType':
return StringType;
case 'numberType':
return NumberType;
case 'booleanType':
return BooleanType;
default:
throw new Error(`Invalid type: ${obj?.object.type}`);
}
})
element!: StringType | NumberType | BooleanType;
}
export class NestedUnionSchema {
@ArrayNotEmpty()
@ValidateNested({ each: true })
@Type(() => DiscriminatedUnionType)
elements!: DiscriminatedUnionType[];
}
Feature Request: https://github.com/epiphone/class-validator-jsonschema/issues/114
similar for oneOf
@rifont ready again:
add tests for enum support of class-validator/-transformer. => done
You may also need to recheck anyOf/allOf etc. f.ex. https://stackoverflow.com/questions/75782271/how-to-validate-nested-array-of-multiple-types-using-class-validator => done (see above)
add tests for validating array of objects should be added as a test (ValidateNested({ each })) => done
What changed? Why was the change needed?
Class Validator support for @novu/framework
Screenhots
Class validator peer dependency import failure message
Expand for optional sections
### Related enterprise PR ### Special notes for your reviewercloses #6682
reference #6840