@@ -16,7 +16,7 @@ import { AdvancedSearchConfig, EventFieldId } from './AdvancedSearchConfig'
1616import { findAllFields , getDeclarationFields } from './utils'
1717import { DeclarationFormConfig } from './FormConfig'
1818import { FieldType } from './FieldType'
19- import { FieldReference , LOCATIONS_FIELD_TYPES } from './FieldConfig'
19+ import { FieldReference } from './FieldConfig'
2020import { FlagConfig , InherentFlags } from './Flag'
2121
2222/**
@@ -34,12 +34,9 @@ export const EventConfig = z
3434 dateOfEvent : FieldReference . optional ( ) . describe (
3535 'Reference to the field capturing the date of the event (e.g. date of birth). Defaults to the event creation date if unspecified.'
3636 ) ,
37- placeOfEvent : z
38- . array ( FieldReference )
39- . optional ( )
40- . describe (
41- 'Reference to the field capturing the place of the event (e.g. place of birth). Defaults to the meta.createdAtLocation if unspecified.'
42- ) ,
37+ placeOfEvent : FieldReference . optional ( ) . describe (
38+ 'Reference to the field capturing the place of the event (e.g. place of birth). Defaults to the meta.createdAtLocation if unspecified.'
39+ ) ,
4340 title : TranslationConfig . describe (
4441 'Title template for the singular event, supporting variables (e.g. "{applicant.name.firstname} {applicant.name.surname}").'
4542 ) ,
@@ -139,28 +136,17 @@ export const EventConfig = z
139136 }
140137 }
141138
142- if ( Array . isArray ( event . placeOfEvent ) ) {
143- const eventPlaceFieldId = getDeclarationFields ( event ) . find ( ( { id } ) =>
144- event . placeOfEvent ?. find ( ( config ) => config . $$field === id )
139+ if ( event . placeOfEvent ) {
140+ const eventPlaceFieldId = getDeclarationFields ( event ) . find (
141+ ( { id } ) => id === event . placeOfEvent ?. $$field
145142 )
146143 if ( ! eventPlaceFieldId ) {
147144 ctx . addIssue ( {
148145 code : 'custom' ,
149- message : `Place of event field id must match a field id in fields array .
150- Invalid place of event field ID for event ${ event . id } : ${ event . placeOfEvent . map ( ( x ) => x . $$field ) . toString ( ) } ` ,
146+ message : `Place of event field id must match a field id in the event.declaration fields .
147+ Invalid place of event field ID for event ${ event . id } : ${ event . placeOfEvent . $$field } ` ,
151148 path : [ 'placeOfEvent' ]
152149 } )
153- } else if (
154- ! ( LOCATIONS_FIELD_TYPES as readonly FieldType [ ] ) . includes (
155- eventPlaceFieldId . type
156- )
157- ) {
158- ctx . addIssue ( {
159- code : 'custom' ,
160- message : `Field specified for place of event is of type: ${ eventPlaceFieldId . type } ,
161- but it needs to be any one of these type: ${ LOCATIONS_FIELD_TYPES . join ( ', ' ) } ` ,
162- path : [ 'placeOfEvent.fieldType' ]
163- } )
164150 }
165151 }
166152
0 commit comments