@timardex/cluemart-shared 1.3.12 → 1.3.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -912,23 +912,31 @@ var listContentSchema = yup9.object({
912
912
  title: yup9.string().optional()
913
913
  }).required()
914
914
  });
915
- var contentDataSchema = yup9.lazy((_, options) => {
916
- const contentType = options.parent?.contentType;
917
- switch (contentType) {
918
- case "cover" /* COVER */:
919
- return coverContentSchema;
920
- case "textarea" /* TEXTAREA */:
921
- return textareaContentSchema;
922
- case "image" /* IMAGE */:
923
- return imagesContentSchema;
924
- case "video" /* VIDEO */:
925
- return videoContentSchema;
926
- case "list" /* LIST */:
927
- return listContentSchema;
928
- default:
929
- return yup9.mixed().required();
915
+ var contentDataSchema = yup9.mixed().required("Content data is required").test(
916
+ "contentData-by-type",
917
+ "Invalid content data for content type",
918
+ function(value) {
919
+ const { contentType } = this.parent;
920
+ const schema = (() => {
921
+ switch (contentType) {
922
+ case "cover" /* COVER */:
923
+ return coverContentSchema;
924
+ case "textarea" /* TEXTAREA */:
925
+ return textareaContentSchema;
926
+ case "image" /* IMAGE */:
927
+ return imagesContentSchema;
928
+ case "video" /* VIDEO */:
929
+ return videoContentSchema;
930
+ case "list" /* LIST */:
931
+ return listContentSchema;
932
+ default:
933
+ return null;
934
+ }
935
+ })();
936
+ if (!schema) return false;
937
+ return schema.isValidSync(value);
930
938
  }
931
- });
939
+ );
932
940
  var postContentSchema = yup9.object().shape({
933
941
  contentData: contentDataSchema,
934
942
  contentOrder: yup9.number().min(0).required(),