@thejob/schema 1.0.29 → 1.0.31

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.
Files changed (27) hide show
  1. package/dist/cjs/interfaces.index.d.ts +5 -40
  2. package/dist/cjs/interfaces.index.d.ts.map +1 -1
  3. package/dist/cjs/job/job.schema.d.ts +1 -8
  4. package/dist/cjs/job/job.schema.d.ts.map +1 -1
  5. package/dist/cjs/job-application/job-application.schema.d.ts +1 -8
  6. package/dist/cjs/job-application/job-application.schema.d.ts.map +1 -1
  7. package/dist/cjs/job-role-template/job-role-template.schema.d.ts +1 -8
  8. package/dist/cjs/job-role-template/job-role-template.schema.d.ts.map +1 -1
  9. package/dist/cjs/question/choice-question.schema.d.ts +1 -8
  10. package/dist/cjs/question/choice-question.schema.d.ts.map +1 -1
  11. package/dist/cjs/question/choice-question.schema.js +6 -7
  12. package/dist/cjs/question/input-question.schema.d.ts.map +1 -1
  13. package/dist/cjs/question/input-question.schema.js +5 -4
  14. package/dist/esm/interfaces.index.d.ts +5 -40
  15. package/dist/esm/interfaces.index.d.ts.map +1 -1
  16. package/dist/esm/job/job.schema.d.ts +1 -8
  17. package/dist/esm/job/job.schema.d.ts.map +1 -1
  18. package/dist/esm/job-application/job-application.schema.d.ts +1 -8
  19. package/dist/esm/job-application/job-application.schema.d.ts.map +1 -1
  20. package/dist/esm/job-role-template/job-role-template.schema.d.ts +1 -8
  21. package/dist/esm/job-role-template/job-role-template.schema.d.ts.map +1 -1
  22. package/dist/esm/question/choice-question.schema.d.ts +1 -8
  23. package/dist/esm/question/choice-question.schema.d.ts.map +1 -1
  24. package/dist/esm/question/choice-question.schema.js +6 -7
  25. package/dist/esm/question/input-question.schema.d.ts.map +1 -1
  26. package/dist/esm/question/input-question.schema.js +5 -4
  27. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"job-role-template.schema.d.ts","sourceRoot":"","sources":["../../../src/job-role-template/job-role-template.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAG5C,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAQhC,CAAC;AAEH,MAAM,MAAM,sBAAsB,GAAG,SAAS,CAAC,OAAO,qBAAqB,CAAC,CAAC"}
1
+ {"version":3,"file":"job-role-template.schema.d.ts","sourceRoot":"","sources":["../../../src/job-role-template/job-role-template.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAG5C,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAQhC,CAAC;AAEH,MAAM,MAAM,sBAAsB,GAAG,SAAS,CAAC,OAAO,qBAAqB,CAAC,CAAC"}
@@ -23,14 +23,7 @@ export declare const ChoiceQuestionSchema: import("yup").ObjectSchema<{
23
23
  } | undefined)[];
24
24
  answerChoiceType: NonNullable<AnswerChoiceType | undefined>;
25
25
  preferredAnswer: TMixedValue | TMixedValue[] | undefined;
26
- answers: TMixedValue | (string | number | boolean | {
27
- logo?: string | undefined;
28
- name: string;
29
- id: string;
30
- } | {
31
- value: "others" | (string | undefined)[];
32
- otherValue: string | string[];
33
- } | undefined)[] | undefined;
26
+ answers: TMixedValue | TMixedValue[] | undefined;
34
27
  }, import("yup").AnyObject, {
35
28
  label: undefined;
36
29
  default: false;
@@ -1 +1 @@
1
- {"version":3,"file":"choice-question.schema.d.ts","sourceRoot":"","sources":["../../../src/question/choice-question.schema.ts"],"names":[],"mappings":"AACA,OAAO,EACL,MAAM,EAKP,MAAM,WAAW,CAAC;AACnB,OAAO,EAAS,SAAS,EAA+B,MAAM,iBAAiB,CAAC;AAChF,OAAO,EACL,gBAAgB,EAChB,YAAY,EAEb,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAkB,WAAW,EAAE,MAAM,mBAAmB,CAAC;AA6HhE,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAkChC,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG,SAAS,CAAC,OAAO,oBAAoB,CAAC,CAAC"}
1
+ {"version":3,"file":"choice-question.schema.d.ts","sourceRoot":"","sources":["../../../src/question/choice-question.schema.ts"],"names":[],"mappings":"AACA,OAAO,EACL,MAAM,EAKP,MAAM,WAAW,CAAC;AACnB,OAAO,EAAS,SAAS,EAA+B,MAAM,iBAAiB,CAAC;AAChF,OAAO,EACL,gBAAgB,EAChB,YAAY,EAEb,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAkB,WAAW,EAAE,MAAM,mBAAmB,CAAC;AA+HhE,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAsChC,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG,SAAS,CAAC,OAAO,oBAAoB,CAAC,CAAC"}
@@ -76,16 +76,15 @@ const ChoicePreferredAnswerSchema = (label = "Preferred answer") => mixed().when
76
76
  .optional()
77
77
  .label(label),
78
78
  });
79
- const ChoiceAnswerSchema = lazy((question) => {
79
+ const getChoiceAnswerSchema = (answerChoiceType, isOptional) => {
80
80
  const commonSchema = mixed().oneOfSchema([
81
- // Note: this can be string, boolean, number, or other complex types
82
81
  string().max(500),
83
82
  NameIdLogoSchema,
84
83
  OtherValueSchema,
85
84
  ]);
86
- if (question.answerChoiceType === AnswerChoiceType.Multiple) {
85
+ if (answerChoiceType === AnswerChoiceType.Multiple) {
87
86
  const multiAnswerSchema = array().of(commonSchema);
88
- if (question.isOptional) {
87
+ if (isOptional) {
89
88
  return multiAnswerSchema.optional().default([]);
90
89
  }
91
90
  else {
@@ -97,14 +96,14 @@ const ChoiceAnswerSchema = lazy((question) => {
97
96
  }
98
97
  else {
99
98
  // Single choice
100
- if (question.isOptional) {
99
+ if (isOptional) {
101
100
  return commonSchema.optional();
102
101
  }
103
102
  else {
104
103
  return commonSchema.required("Select an option.");
105
104
  }
106
105
  }
107
- });
106
+ };
108
107
  export const ChoiceQuestionSchema = QuestionSchema.concat(object().shape({
109
108
  type: string()
110
109
  .oneOf([QuestionType.Choice])
@@ -135,5 +134,5 @@ export const ChoiceQuestionSchema = QuestionSchema.concat(object().shape({
135
134
  .default(AnswerChoiceType.Single)
136
135
  .label("Type"),
137
136
  preferredAnswer: ChoicePreferredAnswerSchema("Preferred answer"),
138
- answers: ChoiceAnswerSchema,
137
+ answers: mixed().when(["answerChoiceType", "isOptional"], ([answerChoiceType, isOptional], schema) => getChoiceAnswerSchema(answerChoiceType, isOptional)),
139
138
  }));
@@ -1 +1 @@
1
- {"version":3,"file":"input-question.schema.d.ts","sourceRoot":"","sources":["../../../src/question/input-question.schema.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAU,YAAY,EAAU,MAAM,iBAAiB,CAAC;AAE1E,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEnD,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;MAe/B,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG,SAAS,CAAC,OAAO,mBAAmB,CAAC,CAAC"}
1
+ {"version":3,"file":"input-question.schema.d.ts","sourceRoot":"","sources":["../../../src/question/input-question.schema.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAU,YAAY,EAAU,MAAM,iBAAiB,CAAC;AAE1E,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEnD,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;MAgB/B,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG,SAAS,CAAC,OAAO,mBAAmB,CAAC,CAAC"}
@@ -11,8 +11,9 @@ export const InputQuestionSchema = QuestionSchema.concat(object().shape({
11
11
  answers: string()
12
12
  .max(500)
13
13
  .when("isOptional", {
14
- is: false,
15
- then: (schema) => schema.required("This field is required."),
16
- otherwise: (schema) => schema.optional(),
17
- }),
14
+ is: (isOptional) => Boolean(isOptional),
15
+ then: (schema) => schema.optional(),
16
+ otherwise: (schema) => schema.required(),
17
+ })
18
+ .label("Answer"),
18
19
  }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thejob/schema",
3
- "version": "1.0.29",
3
+ "version": "1.0.31",
4
4
  "main": "dist/cjs/index.js",
5
5
  "module": "dist/esm/index.js",
6
6
  "types": "dist/esm/index.d.ts",