@defra/forms-model 3.0.625 → 3.0.626

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.
@@ -50,7 +50,7 @@ export const formMetadataInputKeys = {
50
50
  teamEmail: teamEmailSchema,
51
51
  contact: contactSchema,
52
52
  submissionGuidance: submissionGuidanceSchema,
53
- privacyNoticeType: privacyNoticeTypeSchema.default('link'),
53
+ privacyNoticeType: privacyNoticeTypeSchema,
54
54
  privacyNoticeText: Joi.when('privacyNoticeType', {
55
55
  is: 'text',
56
56
  then: privacyNoticeTextSchema,
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["Joi","organisations","idSchema","string","hex","length","required","description","titleSchema","max","trim","slugSchema","pattern","name","organisationSchema","valid","teamNameSchema","teamEmailSchema","email","tlds","allow","phoneSchema","emailAddressSchema","emailResponseTimeSchema","emailSchema","object","keys","address","responseTime","onlineUrlSchema","uri","scheme","onlineTextSchema","onlineSchema","url","text","contactSchema","phone","online","submissionGuidanceSchema","privacyNoticeTypeSchema","privacyNoticeTextSchema","privacyNoticeUrlSchema","termsAndConditionsAgreedSchema","boolean","notificationEmailAddressSchema","authoredAtSchema","date","iso","authorIdSchema","authorDisplayNameSchema","formMetadataInputKeys","title","organisation","teamName","teamEmail","contact","submissionGuidance","privacyNoticeType","default","privacyNoticeText","when","is","then","otherwise","privacyNoticeUrl","termsAndConditionsAgreed","notificationEmail","formMetadataInputSchema","formMetadataAuthorSchema","id","displayName","formMetadataStateSchema","createdAt","createdBy","updatedAt","updatedBy","formVersionMetadataSchema","versionNumber","number","integer","min","formMetadataSchema","append","slug","draft","live","versions","array","items","optional"],"sources":["../../../../src/form/form-metadata/index.ts"],"sourcesContent":["import Joi from 'joi'\n\nimport {\n type FormMetadata,\n type FormMetadataAuthor,\n type FormMetadataContact,\n type FormMetadataContactEmail,\n type FormMetadataContactOnline,\n type FormMetadataInput,\n type FormMetadataState,\n type FormVersionMetadata\n} from '~/src/form/form-metadata/types.js'\n\nexport const organisations = [\n 'Animal and Plant Health Agency – APHA',\n 'Centre for Environment, Fisheries and Aquaculture Science – Cefas',\n 'Defra',\n 'Environment Agency',\n 'Forestry Commission',\n 'Marine Management Organisation – MMO',\n 'Natural England',\n 'Rural Payments Agency – RPA',\n 'Veterinary Medicines Directorate – VMD'\n]\n\nexport const idSchema = Joi.string()\n .hex()\n .length(24)\n .required()\n .description(\n 'Unique identifier for the form, 24-character hexadecimal string'\n )\n\nexport const titleSchema = Joi.string()\n .max(250)\n .trim()\n .required()\n .description('Title of the form, displayed to users')\n\nexport const slugSchema = Joi.string()\n .pattern(/^[a-z0-9-]+$/, { name: 'letters, numbers and hyphens only' })\n .required()\n .description('URL-friendly identifier used in form paths')\n\nexport const organisationSchema = Joi.string()\n .valid(...organisations)\n .required()\n .description('Defra organisation responsible for the form')\n\nexport const teamNameSchema = Joi.string()\n .max(100)\n .trim()\n .required()\n .description('Name of the team responsible for the form')\n\nexport const teamEmailSchema = Joi.string()\n .email({ tlds: { allow: ['uk'] } })\n .trim()\n .required()\n .description('Contact email for the team responsible for the form')\n\nexport const phoneSchema = Joi.string()\n .trim()\n .description('Phone number for form-related inquiries')\n\nexport const emailAddressSchema = Joi.string()\n .email()\n .trim()\n .required()\n .description('Email address for form-related inquiries')\n\nexport const emailResponseTimeSchema = Joi.string()\n .trim()\n .required()\n .description('Expected response time for email inquiries')\n\nexport const emailSchema = Joi.object<FormMetadataContactEmail>()\n .keys({\n address: emailAddressSchema,\n responseTime: emailResponseTimeSchema\n })\n .description('Email contact details including response expectations')\n\nexport const onlineUrlSchema = Joi.string()\n .uri({\n scheme: ['http', 'https']\n })\n .trim()\n .required()\n .description('URL for online contact method')\n\nexport const onlineTextSchema = Joi.string()\n .trim()\n .required()\n .description('Descriptive text for the online contact link')\n\nexport const onlineSchema = Joi.object<FormMetadataContactOnline>()\n .keys({\n url: onlineUrlSchema,\n text: onlineTextSchema\n })\n .description('Online contact details with URL and descriptive text')\n\nexport const contactSchema = Joi.object<FormMetadataContact>()\n .keys({\n phone: phoneSchema,\n email: emailSchema,\n online: onlineSchema\n })\n .description('Complete contact information for form-related inquiries')\n\nexport const submissionGuidanceSchema = Joi.string()\n .trim()\n .description('Guidance text shown to users when submitting the form')\n\nexport const privacyNoticeTypeSchema = Joi.string()\n .valid('text', 'link')\n .description('Type of privacy notice content')\n\nexport const privacyNoticeTextSchema = Joi.string()\n .trim()\n .description('URL to the privacy notice for this form')\n\nexport const privacyNoticeUrlSchema = Joi.string()\n .uri({\n scheme: ['http', 'https']\n })\n .trim()\n .description('URL to the privacy notice for this form')\n\nexport const termsAndConditionsAgreedSchema = Joi.boolean().description(\n 'Whether the data protection terms and conditions have been agreed to'\n)\n\nexport const notificationEmailAddressSchema = Joi.string()\n .email()\n .trim()\n .description('Email address to receive form submission notifications')\n\nexport const authoredAtSchema = Joi.date()\n .iso()\n .required()\n .description('ISO format timestamp of when an action occurred')\n\nexport const authorIdSchema = Joi.string()\n .trim()\n .required()\n .description('Unique identifier for the author')\n\nexport const authorDisplayNameSchema = Joi.string()\n .trim()\n .required()\n .description('Human-readable name of the author')\n\nexport const formMetadataInputKeys = {\n title: titleSchema,\n organisation: organisationSchema,\n teamName: teamNameSchema,\n teamEmail: teamEmailSchema,\n contact: contactSchema,\n submissionGuidance: submissionGuidanceSchema,\n privacyNoticeType: privacyNoticeTypeSchema.default('link'),\n privacyNoticeText: Joi.when('privacyNoticeType', {\n is: 'text',\n then: privacyNoticeTextSchema,\n otherwise: privacyNoticeTextSchema.allow('')\n }),\n privacyNoticeUrl: Joi.when('privacyNoticeType', {\n is: 'link',\n then: privacyNoticeUrlSchema,\n otherwise: privacyNoticeUrlSchema.allow('')\n }),\n termsAndConditionsAgreed: termsAndConditionsAgreedSchema,\n notificationEmail: notificationEmailAddressSchema\n}\n\n/**\n * Joi schema for `FormMetadataInput` interface\n * @see {@link FormMetadataInput}\n */\nexport const formMetadataInputSchema = Joi.object<FormMetadataInput>()\n .keys(formMetadataInputKeys)\n .required()\n .description('Input data for creating or updating form metadata')\n\n/**\n * Joi schema for `FormMetadataAuthor` interface\n * @see {@link FormMetadataAuthor}\n */\nexport const formMetadataAuthorSchema = Joi.object<FormMetadataAuthor>()\n .keys({\n id: authorIdSchema,\n displayName: authorDisplayNameSchema\n })\n .required()\n .description('Information about the author of a form or form change')\n\n/**\n * Joi schema for `FormMetadataState` interface\n * @see {@link FormMetadataState}\n */\nexport const formMetadataStateSchema = Joi.object<FormMetadataState>()\n .keys({\n createdAt: authoredAtSchema.description(\n 'When this version was first created'\n ),\n createdBy: formMetadataAuthorSchema.description('Who created this version'),\n updatedAt: authoredAtSchema.description(\n 'When this version was last updated'\n ),\n updatedBy: formMetadataAuthorSchema.description(\n 'Who last updated this version'\n )\n })\n .description('Metadata about a specific version state (draft or live)')\n\n/**\n * Joi schema for `FormVersionMetadata` interface\n * @see {@link FormVersionMetadata}\n */\nexport const formVersionMetadataSchema = Joi.object<FormVersionMetadata>()\n .keys({\n versionNumber: Joi.number()\n .integer()\n .min(1)\n .required()\n .description('The version number'),\n createdAt: authoredAtSchema.description('When this version was created')\n })\n .description('Metadata for a specific version of the form')\n\n/**\n * Joi schema for `FormMetadata` interface\n * @see {@link FormMetadata}\n */\nexport const formMetadataSchema = formMetadataInputSchema\n .append<FormMetadata>({\n id: idSchema,\n slug: slugSchema,\n draft: formMetadataStateSchema.description(\n 'Metadata for the draft version'\n ),\n live: formMetadataStateSchema.description(\n 'Metadata for the published version'\n ),\n createdAt: authoredAtSchema.description('When the form was first created'),\n createdBy: formMetadataAuthorSchema.description('Who created the form'),\n updatedAt: authoredAtSchema.description('When the form was last updated'),\n updatedBy: formMetadataAuthorSchema.description(\n 'Who last updated the form'\n ),\n versions: Joi.array()\n .items(formVersionMetadataSchema)\n .optional()\n .description('Version history for the form')\n })\n .description(\n 'Complete metadata for a form, including version information and authoring details'\n )\n"],"mappings":"AAAA,OAAOA,GAAG,MAAM,KAAK;AAarB,OAAO,MAAMC,aAAa,GAA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CACF,CAAC;EACD+E,IAAI,EAAEd,uBAAuB,CAACjE,WAAW,CACvC,oCACF,CAAC;EACDkE,SAAS,EAAE3B,gBAAgB,CAACvC,WAAW,CAAC,iCAAiC,CAAC;EAC1EmE,SAAS,EAAEL,wBAAwB,CAAC9D,WAAW,CAAC,sBAAsB,CAAC;EACvEoE,SAAS,EAAE7B,gBAAgB,CAACvC,WAAW,CAAC,gCAAgC,CAAC;EACzEqE,SAAS,EAAEP,wBAAwB,CAAC9D,WAAW,CAC7C,2BACF,CAAC;EACDgF,QAAQ,EAAEvF,GAAG,CAACwF,KAAK,CAAC,CAAC,CAClBC,KAAK,CAACZ,yBAAyB,CAAC,CAChCa,QAAQ,CAAC,CAAC,CACVnF,WAAW,CAAC,8BAA8B;AAC/C,CAAC,CAAC,CACDA,WAAW,CACV,mFACF,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["Joi","organisations","idSchema","string","hex","length","required","description","titleSchema","max","trim","slugSchema","pattern","name","organisationSchema","valid","teamNameSchema","teamEmailSchema","email","tlds","allow","phoneSchema","emailAddressSchema","emailResponseTimeSchema","emailSchema","object","keys","address","responseTime","onlineUrlSchema","uri","scheme","onlineTextSchema","onlineSchema","url","text","contactSchema","phone","online","submissionGuidanceSchema","privacyNoticeTypeSchema","privacyNoticeTextSchema","privacyNoticeUrlSchema","termsAndConditionsAgreedSchema","boolean","notificationEmailAddressSchema","authoredAtSchema","date","iso","authorIdSchema","authorDisplayNameSchema","formMetadataInputKeys","title","organisation","teamName","teamEmail","contact","submissionGuidance","privacyNoticeType","privacyNoticeText","when","is","then","otherwise","privacyNoticeUrl","termsAndConditionsAgreed","notificationEmail","formMetadataInputSchema","formMetadataAuthorSchema","id","displayName","formMetadataStateSchema","createdAt","createdBy","updatedAt","updatedBy","formVersionMetadataSchema","versionNumber","number","integer","min","formMetadataSchema","append","slug","draft","live","versions","array","items","optional"],"sources":["../../../../src/form/form-metadata/index.ts"],"sourcesContent":["import Joi from 'joi'\n\nimport {\n type FormMetadata,\n type FormMetadataAuthor,\n type FormMetadataContact,\n type FormMetadataContactEmail,\n type FormMetadataContactOnline,\n type FormMetadataInput,\n type FormMetadataState,\n type FormVersionMetadata\n} from '~/src/form/form-metadata/types.js'\n\nexport const organisations = [\n 'Animal and Plant Health Agency – APHA',\n 'Centre for Environment, Fisheries and Aquaculture Science – Cefas',\n 'Defra',\n 'Environment Agency',\n 'Forestry Commission',\n 'Marine Management Organisation – MMO',\n 'Natural England',\n 'Rural Payments Agency – RPA',\n 'Veterinary Medicines Directorate – VMD'\n]\n\nexport const idSchema = Joi.string()\n .hex()\n .length(24)\n .required()\n .description(\n 'Unique identifier for the form, 24-character hexadecimal string'\n )\n\nexport const titleSchema = Joi.string()\n .max(250)\n .trim()\n .required()\n .description('Title of the form, displayed to users')\n\nexport const slugSchema = Joi.string()\n .pattern(/^[a-z0-9-]+$/, { name: 'letters, numbers and hyphens only' })\n .required()\n .description('URL-friendly identifier used in form paths')\n\nexport const organisationSchema = Joi.string()\n .valid(...organisations)\n .required()\n .description('Defra organisation responsible for the form')\n\nexport const teamNameSchema = Joi.string()\n .max(100)\n .trim()\n .required()\n .description('Name of the team responsible for the form')\n\nexport const teamEmailSchema = Joi.string()\n .email({ tlds: { allow: ['uk'] } })\n .trim()\n .required()\n .description('Contact email for the team responsible for the form')\n\nexport const phoneSchema = Joi.string()\n .trim()\n .description('Phone number for form-related inquiries')\n\nexport const emailAddressSchema = Joi.string()\n .email()\n .trim()\n .required()\n .description('Email address for form-related inquiries')\n\nexport const emailResponseTimeSchema = Joi.string()\n .trim()\n .required()\n .description('Expected response time for email inquiries')\n\nexport const emailSchema = Joi.object<FormMetadataContactEmail>()\n .keys({\n address: emailAddressSchema,\n responseTime: emailResponseTimeSchema\n })\n .description('Email contact details including response expectations')\n\nexport const onlineUrlSchema = Joi.string()\n .uri({\n scheme: ['http', 'https']\n })\n .trim()\n .required()\n .description('URL for online contact method')\n\nexport const onlineTextSchema = Joi.string()\n .trim()\n .required()\n .description('Descriptive text for the online contact link')\n\nexport const onlineSchema = Joi.object<FormMetadataContactOnline>()\n .keys({\n url: onlineUrlSchema,\n text: onlineTextSchema\n })\n .description('Online contact details with URL and descriptive text')\n\nexport const contactSchema = Joi.object<FormMetadataContact>()\n .keys({\n phone: phoneSchema,\n email: emailSchema,\n online: onlineSchema\n })\n .description('Complete contact information for form-related inquiries')\n\nexport const submissionGuidanceSchema = Joi.string()\n .trim()\n .description('Guidance text shown to users when submitting the form')\n\nexport const privacyNoticeTypeSchema = Joi.string()\n .valid('text', 'link')\n .description('Type of privacy notice content')\n\nexport const privacyNoticeTextSchema = Joi.string()\n .trim()\n .description('URL to the privacy notice for this form')\n\nexport const privacyNoticeUrlSchema = Joi.string()\n .uri({\n scheme: ['http', 'https']\n })\n .trim()\n .description('URL to the privacy notice for this form')\n\nexport const termsAndConditionsAgreedSchema = Joi.boolean().description(\n 'Whether the data protection terms and conditions have been agreed to'\n)\n\nexport const notificationEmailAddressSchema = Joi.string()\n .email()\n .trim()\n .description('Email address to receive form submission notifications')\n\nexport const authoredAtSchema = Joi.date()\n .iso()\n .required()\n .description('ISO format timestamp of when an action occurred')\n\nexport const authorIdSchema = Joi.string()\n .trim()\n .required()\n .description('Unique identifier for the author')\n\nexport const authorDisplayNameSchema = Joi.string()\n .trim()\n .required()\n .description('Human-readable name of the author')\n\nexport const formMetadataInputKeys = {\n title: titleSchema,\n organisation: organisationSchema,\n teamName: teamNameSchema,\n teamEmail: teamEmailSchema,\n contact: contactSchema,\n submissionGuidance: submissionGuidanceSchema,\n privacyNoticeType: privacyNoticeTypeSchema,\n privacyNoticeText: Joi.when('privacyNoticeType', {\n is: 'text',\n then: privacyNoticeTextSchema,\n otherwise: privacyNoticeTextSchema.allow('')\n }),\n privacyNoticeUrl: Joi.when('privacyNoticeType', {\n is: 'link',\n then: privacyNoticeUrlSchema,\n otherwise: privacyNoticeUrlSchema.allow('')\n }),\n termsAndConditionsAgreed: termsAndConditionsAgreedSchema,\n notificationEmail: notificationEmailAddressSchema\n}\n\n/**\n * Joi schema for `FormMetadataInput` interface\n * @see {@link FormMetadataInput}\n */\nexport const formMetadataInputSchema = Joi.object<FormMetadataInput>()\n .keys(formMetadataInputKeys)\n .required()\n .description('Input data for creating or updating form metadata')\n\n/**\n * Joi schema for `FormMetadataAuthor` interface\n * @see {@link FormMetadataAuthor}\n */\nexport const formMetadataAuthorSchema = Joi.object<FormMetadataAuthor>()\n .keys({\n id: authorIdSchema,\n displayName: authorDisplayNameSchema\n })\n .required()\n .description('Information about the author of a form or form change')\n\n/**\n * Joi schema for `FormMetadataState` interface\n * @see {@link FormMetadataState}\n */\nexport const formMetadataStateSchema = Joi.object<FormMetadataState>()\n .keys({\n createdAt: authoredAtSchema.description(\n 'When this version was first created'\n ),\n createdBy: formMetadataAuthorSchema.description('Who created this version'),\n updatedAt: authoredAtSchema.description(\n 'When this version was last updated'\n ),\n updatedBy: formMetadataAuthorSchema.description(\n 'Who last updated this version'\n )\n })\n .description('Metadata about a specific version state (draft or live)')\n\n/**\n * Joi schema for `FormVersionMetadata` interface\n * @see {@link FormVersionMetadata}\n */\nexport const formVersionMetadataSchema = Joi.object<FormVersionMetadata>()\n .keys({\n versionNumber: Joi.number()\n .integer()\n .min(1)\n .required()\n .description('The version number'),\n createdAt: authoredAtSchema.description('When this version was created')\n })\n .description('Metadata for a specific version of the form')\n\n/**\n * Joi schema for `FormMetadata` interface\n * @see {@link FormMetadata}\n */\nexport const formMetadataSchema = formMetadataInputSchema\n .append<FormMetadata>({\n id: idSchema,\n slug: slugSchema,\n draft: formMetadataStateSchema.description(\n 'Metadata for the draft version'\n ),\n live: formMetadataStateSchema.description(\n 'Metadata for the published version'\n ),\n createdAt: authoredAtSchema.description('When the form was first created'),\n createdBy: formMetadataAuthorSchema.description('Who created the form'),\n updatedAt: authoredAtSchema.description('When the form was last updated'),\n updatedBy: formMetadataAuthorSchema.description(\n 'Who last updated the form'\n ),\n versions: Joi.array()\n .items(formVersionMetadataSchema)\n .optional()\n .description('Version history for the form')\n })\n .description(\n 'Complete metadata for a form, including version information and authoring details'\n )\n"],"mappings":"AAAA,OAAOA,GAAG,MAAM,KAAK;AAarB,OAAO,MAAMC,aAAa,GAAG,CAC3B,uCAAuC,EACvC,mEAAmE,EACnE,OAAO,EACP,oBAAoB,EACpB,qBAAqB,EACrB,sCAAsC,EACtC,iBAAiB,EACjB,6BAA6B,EAC7B,wCAAwC,CACzC;AAED,OAAO,MAAMC,QAAQ,GAAGF,GAAG,CAACG,MAAM,CAAC,CAAC,CACjCC,GAAG,CAAC,CAAC,CACLC,MAAM,CAAC,EAAE,CAAC,CACVC,QAAQ,CAAC,CAAC,CACVC,WAAW,CACV,iEACF,CAAC;AAEH,OAAO,MAAMC,WAAW,GAAGR,GAAG,CAACG,MAAM,CAAC,CAAC,CACpCM,GAAG,CAAC,GAAG,CAAC,CACRC,IAAI,CAAC,CAAC,CACNJ,QAAQ,CAAC,CAAC,CACVC,WAAW,CAAC,uCAAuC,CAAC;AAEvD,OAAO,MAAMI,UAAU,GAAGX,GAAG,CAACG,MAAM,CAAC,CAAC,CACnCS,OAAO,CAAC,cAAc,EAAE;EAAEC,IAAI,EAAE;AAAoC,CAAC,CAAC,CACtEP,QAAQ,CAAC,CAAC,CACVC,WAAW,CAAC,4CAA4C,CAAC;AAE5D,OAAO,MAAMO,kBAAkB,GAAGd,GAAG,CAACG,MAAM,CAAC,CAAC,CAC3CY,KAAK,CAAC,GAAGd,aAAa,CAAC,CACvBK,QAAQ,CAAC,CAAC,CACVC,WAAW,CAAC,6CAA6C,CAAC;AAE7D,OAAO,MAAMS,cAAc,GAAGhB,GAAG,CAACG,MAAM,CAAC,CAAC,CACvCM,GAAG,CAAC,GAAG,CAAC,CACRC,IAAI,CAAC,CAAC,CACNJ,QAAQ,CAAC,CAAC,CACVC,WAAW,CAAC,2CAA2C,CAAC;AAE3D,OAAO,MAAMU,eAAe,GAAGjB,GAAG,CAACG,MAAM,CAAC,CAAC,CACxC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e;EACpBb,EAAE,EAAEnE,QAAQ;EACZiF,IAAI,EAAExE,UAAU;EAChByE,KAAK,EAAEb,uBAAuB,CAAChE,WAAW,CACxC,gCACF,CAAC;EACD8E,IAAI,EAAEd,uBAAuB,CAAChE,WAAW,CACvC,oCACF,CAAC;EACDiE,SAAS,EAAE1B,gBAAgB,CAACvC,WAAW,CAAC,iCAAiC,CAAC;EAC1EkE,SAAS,EAAEL,wBAAwB,CAAC7D,WAAW,CAAC,sBAAsB,CAAC;EACvEmE,SAAS,EAAE5B,gBAAgB,CAACvC,WAAW,CAAC,gCAAgC,CAAC;EACzEoE,SAAS,EAAEP,wBAAwB,CAAC7D,WAAW,CAC7C,2BACF,CAAC;EACD+E,QAAQ,EAAEtF,GAAG,CAACuF,KAAK,CAAC,CAAC,CAClBC,KAAK,CAACZ,yBAAyB,CAAC,CAChCa,QAAQ,CAAC,CAAC,CACVlF,WAAW,CAAC,8BAA8B;AAC/C,CAAC,CAAC,CACDA,WAAW,CACV,mFACF,CAAC","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@defra/forms-model",
3
- "version": "3.0.625",
3
+ "version": "3.0.626",
4
4
  "description": "A hapi plugin providing the model for Defra forms",
5
5
  "homepage": "https://github.com/DEFRA/forms-designer/tree/main/model#readme",
6
6
  "types": "dist/types/index.d.ts",
@@ -103,7 +103,6 @@
103
103
  "privacyNoticeType": {
104
104
  "type": "string",
105
105
  "description": "Type of privacy notice content",
106
- "default": "link",
107
106
  "enum": [
108
107
  "text",
109
108
  "link"
@@ -103,7 +103,6 @@
103
103
  "privacyNoticeType": {
104
104
  "type": "string",
105
105
  "description": "Type of privacy notice content",
106
- "default": "link",
107
106
  "enum": [
108
107
  "text",
109
108
  "link"
@@ -159,7 +159,7 @@ export const formMetadataInputKeys = {
159
159
  teamEmail: teamEmailSchema,
160
160
  contact: contactSchema,
161
161
  submissionGuidance: submissionGuidanceSchema,
162
- privacyNoticeType: privacyNoticeTypeSchema.default('link'),
162
+ privacyNoticeType: privacyNoticeTypeSchema,
163
163
  privacyNoticeText: Joi.when('privacyNoticeType', {
164
164
  is: 'text',
165
165
  then: privacyNoticeTextSchema,