@thejob/schema 1.0.29 → 1.0.30
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.
- package/dist/cjs/interfaces.index.d.ts +5 -40
- package/dist/cjs/interfaces.index.d.ts.map +1 -1
- package/dist/cjs/job/job.schema.d.ts +1 -8
- package/dist/cjs/job/job.schema.d.ts.map +1 -1
- package/dist/cjs/job-application/job-application.schema.d.ts +1 -8
- package/dist/cjs/job-application/job-application.schema.d.ts.map +1 -1
- package/dist/cjs/job-role-template/job-role-template.schema.d.ts +1 -8
- package/dist/cjs/job-role-template/job-role-template.schema.d.ts.map +1 -1
- package/dist/cjs/question/choice-question.schema.d.ts +1 -8
- package/dist/cjs/question/choice-question.schema.d.ts.map +1 -1
- package/dist/cjs/question/choice-question.schema.js +6 -7
- package/dist/esm/interfaces.index.d.ts +5 -40
- package/dist/esm/interfaces.index.d.ts.map +1 -1
- package/dist/esm/job/job.schema.d.ts +1 -8
- package/dist/esm/job/job.schema.d.ts.map +1 -1
- package/dist/esm/job-application/job-application.schema.d.ts +1 -8
- package/dist/esm/job-application/job-application.schema.d.ts.map +1 -1
- package/dist/esm/job-role-template/job-role-template.schema.d.ts +1 -8
- package/dist/esm/job-role-template/job-role-template.schema.d.ts.map +1 -1
- package/dist/esm/question/choice-question.schema.d.ts +1 -8
- package/dist/esm/question/choice-question.schema.d.ts.map +1 -1
- package/dist/esm/question/choice-question.schema.js +6 -7
- package/package.json +1 -1
|
@@ -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;
|
|
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
|
|
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 (
|
|
85
|
+
if (answerChoiceType === AnswerChoiceType.Multiple) {
|
|
87
86
|
const multiAnswerSchema = array().of(commonSchema);
|
|
88
|
-
if (
|
|
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 (
|
|
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:
|
|
137
|
+
answers: mixed().when(["answerChoiceType", "isOptional"], ([answerChoiceType, isOptional], schema) => getChoiceAnswerSchema(answerChoiceType, isOptional)),
|
|
139
138
|
}));
|