@forwardslashns/taskit-validation-messages 1.0.24 → 1.0.26

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/.prettierrc ADDED
@@ -0,0 +1,8 @@
1
+ {
2
+ "trailingComma": "es5",
3
+ "tabWidth": 2,
4
+ "semi": true,
5
+ "singleQuote": true,
6
+ "printWidth": 120,
7
+ "endOfLine": "auto"
8
+ }
package/README.md CHANGED
@@ -8,4 +8,4 @@ The package exposes validation messages that can be retrieved using specific ali
8
8
 
9
9
  # getValidationMessage
10
10
 
11
- This mechanism allows for the retrieval and dynamic creation of validation messages by passing their aliases and any required parameters. Parameters are optional and passed as objects, following the structure defined within each validation message itself.
11
+ This mechanism allows for the retrieval and dynamic creation of validation messages by passing their aliases and any required parameters. Parameters are optional and passed as objects, following the structure defined within each validation message itself.
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { getValidationMessage } from "./validation/validation-message.formatter";
2
- import { VALIDATION_MESSAGES } from "./validation/validation-messages";
1
+ import { getValidationMessage } from './validation/validation-message.formatter';
2
+ import { VALIDATION_MESSAGES } from './validation/validation-messages';
3
3
  export { VALIDATION_MESSAGES, getValidationMessage };
4
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"validation-message.formatter.d.ts","sourceRoot":"","sources":["../../src/validation/validation-message.formatter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,KAAK,QAAQ,GAAG,MAAM,OAAO,mBAAmB,CAAC;AACjD,KAAK,SAAS,CAAC,CAAC,SAAS,QAAQ,IAAI,MAAM,CAAC,OAAO,mBAAmB,CAAC,CAAC,CAAC,CAAC,CAAC;AAC3E,KAAK,kBAAkB,CACrB,CAAC,SAAS,QAAQ,EAClB,CAAC,SAAS,SAAS,CAAC,CAAC,CAAC,IACpB,CAAC,OAAO,mBAAmB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS;IAC7C,MAAM,EAAE,MAAM,CAAC,SAAS,SAAS,MAAM,EAAE,CAAC;CAC3C,GACG,CAAC,GACD,EAAE,CAAC;AACP,KAAK,aAAa,CAAC,CAAC,SAAS,SAAS,MAAM,EAAE,IAAI;KAAG,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,GAAG,MAAM;CAAE,CAAC;AAM/E,eAAO,MAAM,oBAAoB,GAC/B,WAAW,SAAS,QAAQ,EAC5B,gBAAgB,SAAS,SAAS,CAAC,WAAW,CAAC,EAE/C,SAAS,WAAW,EACpB,cAAc,gBAAgB,EAC9B,SAAS,aAAa,CAAC,kBAAkB,CAAC,WAAW,EAAE,gBAAgB,CAAC,CAAC,KACxE,MAuDF,CAAC"}
1
+ {"version":3,"file":"validation-message.formatter.d.ts","sourceRoot":"","sources":["../../src/validation/validation-message.formatter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,KAAK,QAAQ,GAAG,MAAM,OAAO,mBAAmB,CAAC;AACjD,KAAK,SAAS,CAAC,CAAC,SAAS,QAAQ,IAAI,MAAM,CAAC,OAAO,mBAAmB,CAAC,CAAC,CAAC,CAAC,CAAC;AAC3E,KAAK,kBAAkB,CAAC,CAAC,SAAS,QAAQ,EAAE,CAAC,SAAS,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,mBAAmB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS;IAC/G,MAAM,EAAE,MAAM,CAAC,SAAS,SAAS,MAAM,EAAE,CAAC;CAC3C,GACG,CAAC,GACD,EAAE,CAAC;AACP,KAAK,aAAa,CAAC,CAAC,SAAS,SAAS,MAAM,EAAE,IAAI;KAAG,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,GAAG,MAAM;CAAE,CAAC;AAM/E,eAAO,MAAM,oBAAoB,GAAI,WAAW,SAAS,QAAQ,EAAE,gBAAgB,SAAS,SAAS,CAAC,WAAW,CAAC,EAChH,SAAS,WAAW,EACpB,cAAc,gBAAgB,EAC9B,SAAS,aAAa,CAAC,kBAAkB,CAAC,WAAW,EAAE,gBAAgB,CAAC,CAAC,KACxE,MA4CF,CAAC"}
@@ -10,9 +10,7 @@ const getValidationMessage = (feature, featureError, params) => {
10
10
  const inputParams = params || {};
11
11
  const errorSuffix = `for feature: ${String(feature)}, error: ${String(featureError)}`;
12
12
  let message = messageConfig.message;
13
- const expectedParams = messageConfig.params?.length
14
- ? messageConfig.params
15
- : [];
13
+ const expectedParams = messageConfig.params?.length ? messageConfig.params : [];
16
14
  if (!message) {
17
15
  throw new Error(`Validation error message is not defined properly in configuration ${errorSuffix}`);
18
16
  }
@@ -214,7 +214,7 @@ export declare const VALIDATION_MESSAGES: {
214
214
  readonly message: "States Starting Date cannot be Empty";
215
215
  };
216
216
  readonly NOT_ALIGNED_STATE_STARTING_ENDING_DATE: {
217
- readonly message: "Domestic state starting date needs to be before the ending date";
217
+ readonly message: "State starting date needs to be before the ending date";
218
218
  };
219
219
  readonly NOT_ALIGNED_DATE_ESTABLISHED_STATES_STARTING_DATE: {
220
220
  readonly message: "Adjust the start date to be on or after the client's date established, {clientStartDate}.";
@@ -237,12 +237,92 @@ export declare const VALIDATION_MESSAGES: {
237
237
  readonly params: readonly ["dateEstablished", "earliestState", "earliestStateStartDate"];
238
238
  };
239
239
  readonly STATES_DATES_OVERLAP: {
240
- readonly message: "There cannot be two {residence} states in the same timeframe. The state of {state} has a timeframe starting {stateStartDate} and ending {stateEndDate}. Please adjust the dates on the new or existing domestic state/s to avoid an overlap.";
241
- readonly params: readonly ["state", "stateStartDate", "stateEndDate", "residence"];
240
+ readonly message: "There are multiple entries for {state} with overlapping timeframes: {state} from {startDate1} to {endDate1}, {state} from {startDate2} to {endDate2}. A state cannot appear more than once with overlapping dates, even if the residence type is different. Please adjust the dates on the new or existing {state} entries to remove the overlap.";
241
+ readonly params: readonly ["state", "startDate1", "endDate1", "startDate2", "endDate2"];
242
242
  };
243
243
  readonly ALL_NON_LAST_DOMESTIC_STATES_REQUIRE_ENDING_DATE: {
244
244
  readonly message: "Only the last domestic state can be open without an end date. Add an ending date to the existing state before adding a start date for a new state.";
245
245
  };
246
+ readonly ENTITY_TYPES_IDS_DOES_NOT_EXIST: {
247
+ readonly message: "Entity types with ids '{ids}' do not exist";
248
+ readonly params: readonly ["ids"];
249
+ };
250
+ readonly AT_LEAST_ONE_ENTITY_TYPE_SHOULD_EXIST: {
251
+ readonly message: "At least one entity type should exist";
252
+ };
253
+ readonly ENTITY_TYPES_STARTING_DATE_NOT_POPULATED: {
254
+ readonly message: "Entity Type Starting Date cannot be Empty";
255
+ };
256
+ readonly NOT_ALIGNED_ENTITY_TYPES_STARTING_ENDING_DATE: {
257
+ readonly message: "Entity type starting date needs to be before the ending date";
258
+ };
259
+ readonly NOT_ALIGNED_DATE_ESTABLISHED_ENTITY_TYPES_STARTING_DATE: {
260
+ readonly message: "Adjust the start date to be on or after the client's date established, {clientStartDate}.";
261
+ readonly params: readonly ["clientStartDate"];
262
+ };
263
+ readonly NOT_ALIGNED_CLOSE_DATE_ENTITY_TYPES_STARTING_DATE: {
264
+ readonly message: "Adjust the start date to be before the client's close date, {clientCloseDate}.";
265
+ readonly params: readonly ["clientCloseDate"];
266
+ };
267
+ readonly ENTITY_TYPES_DATE_GAP_DETECTED: {
268
+ readonly message: "There is a gap in the timeframes between {currentEntityType}, ending {currentEntityTypeEndDate}, and {nextEntityType}, starting {nextEntityTypeStartDate}. Please adjust the dates to fill this gap.";
269
+ readonly params: readonly ["currentEntityType", "currentEntityTypeEndDate", "nextEntityType", "nextEntityTypeStartDate"];
270
+ };
271
+ readonly ENTITY_TYPES_CONSECUTIVE_DUPLICATES_DETECTED: {
272
+ readonly message: "There are two entries for {entityType} with timeframes that immediately follow each other. {entityType} ending {firstPeriodEnd}, and {entityType} starting {secondPeriodStart}. Please update one entry to include the entire timeframe for {entityType}. ";
273
+ readonly params: readonly ["entityType", "firstPeriodStart", "firstPeriodEnd", "secondPeriodStart"];
274
+ };
275
+ readonly ENTITY_TYPE_EARLIEST_AND_DATE_ESTABLISHED_GAP_DETECTED: {
276
+ readonly message: "There is a gap between the client's date established ({dateEstablished}) and the start of its first entity type ({earliestEntityType} starting {earliestEntityTypeStartDate}). There must be an entity type that begins on {dateEstablished}.";
277
+ readonly params: readonly ["dateEstablished", "earliestEntityType", "earliestEntityTypeStartDate"];
278
+ };
279
+ readonly ENTITY_TYPES_DATES_OVERLAP: {
280
+ readonly message: "There are multiple entries for {entityType} with overlapping timeframes: {entityType} from {startDate1} to {endDate1}, {entityType} from {startDate2} to {endDate2}. An entity type cannot appear more than once with overlapping dates. Please adjust the dates on the new or existing {entityType} entries to remove the overlap.";
281
+ readonly params: readonly ["entityType", "startDate1", "endDate1", "startDate2", "endDate2"];
282
+ };
283
+ readonly ALL_NON_LAST_ENTITY_TYPES_REQUIRE_ENDING_DATE: {
284
+ readonly message: "Only the last entity type can be open without an end date. Add an ending date to the existing entity type before adding a start date for a new entity type.";
285
+ };
286
+ readonly FILING_TYPES_IDS_DOES_NOT_EXIST: {
287
+ readonly message: "Filing types with ids '{ids}' do not exist";
288
+ readonly params: readonly ["ids"];
289
+ };
290
+ readonly AT_LEAST_ONE_FILING_TYPE_SHOULD_EXIST: {
291
+ readonly message: "At least one filing type should exist";
292
+ };
293
+ readonly FILING_TYPES_STARTING_DATE_NOT_POPULATED: {
294
+ readonly message: "Filing Type Starting Date cannot be Empty";
295
+ };
296
+ readonly NOT_ALIGNED_FILING_TYPES_STARTING_ENDING_DATE: {
297
+ readonly message: "Filing type starting date needs to be before the ending date";
298
+ };
299
+ readonly NOT_ALIGNED_DATE_ESTABLISHED_FILING_TYPES_STARTING_DATE: {
300
+ readonly message: "Adjust the start date to be on or after the client's date established, {clientStartDate}.";
301
+ readonly params: readonly ["clientStartDate"];
302
+ };
303
+ readonly NOT_ALIGNED_CLOSE_DATE_FILING_TYPES_STARTING_DATE: {
304
+ readonly message: "Adjust the start date to be before the client's close date, {clientCloseDate}.";
305
+ readonly params: readonly ["clientCloseDate"];
306
+ };
307
+ readonly FILING_TYPES_DATE_GAP_DETECTED: {
308
+ readonly message: "There is a gap in the timeframes between {currentFilingType}, ending {currentFilingTypeEndDate}, and {nextFilingType}, starting {nextFilingTypeStartDate}. Please adjust the dates to fill this gap.";
309
+ readonly params: readonly ["currentFilingType", "currentFilingTypeEndDate", "nextFilingType", "nextFilingTypeStartDate"];
310
+ };
311
+ readonly FILING_TYPES_CONSECUTIVE_DUPLICATES_DETECTED: {
312
+ readonly message: "There are two entries for {filingType} with timeframes that immediately follow each other. {filingType} ending {firstPeriodEnd}, and {filingType} starting {secondPeriodStart}. Please update one entry to include the entire timeframe for {filingType}. ";
313
+ readonly params: readonly ["filingType", "firstPeriodStart", "firstPeriodEnd", "secondPeriodStart"];
314
+ };
315
+ readonly FILING_TYPE_EARLIEST_AND_DATE_ESTABLISHED_GAP_DETECTED: {
316
+ readonly message: "There is a gap between the client's date established ({dateEstablished}) and the start of its first filing type ({earliestFilingType} starting {earliestFilingTypeStartDate}). There must be a filing type that begins on {dateEstablished}.";
317
+ readonly params: readonly ["dateEstablished", "earliestFilingType", "earliestFilingTypeStartDate"];
318
+ };
319
+ readonly FILING_TYPES_DATES_OVERLAP: {
320
+ readonly message: "There are multiple entries for {filingType} with overlapping timeframes: {filingType} from {startDate1} to {endDate1}, {filingType} from {startDate2} to {endDate2}. A filing type cannot appear more than once with overlapping dates. Please adjust the dates on the new or existing {filingType} entries to remove the overlap.";
321
+ readonly params: readonly ["filingType", "startDate1", "endDate1", "startDate2", "endDate2"];
322
+ };
323
+ readonly ALL_NON_LAST_FILING_TYPES_REQUIRE_ENDING_DATE: {
324
+ readonly message: "Only the last filing type can be open without an end date. Add an ending date to the existing filing type before adding a start date for a new filing type.";
325
+ };
246
326
  };
247
327
  readonly FILING_CATEGORY: {
248
328
  readonly INVALID_REQUEST: {
@@ -1 +1 @@
1
- {"version":3,"file":"validation-messages.d.ts","sourceRoot":"","sources":["../../src/validation/validation-messages.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+VtB,CAAC"}
1
+ {"version":3,"file":"validation-messages.d.ts","sourceRoot":"","sources":["../../src/validation/validation-messages.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2atB,CAAC"}
@@ -114,11 +114,7 @@ exports.VALIDATION_MESSAGES = {
114
114
  },
115
115
  NOT_ALIGNED_DATE_ESTABLISHED_DOMESTIC_STATE_STARTING_DATE: {
116
116
  message: `The state, {domesticState}, starts on {domesticStateStartingDate}, which is earlier than the client's date established, {clientDateEstablished}. Please adjust the start date of the state or the client's date established.`,
117
- params: [
118
- 'clientDateEstablished',
119
- 'domesticState',
120
- 'domesticStateStartingDate',
121
- ],
117
+ params: ['clientDateEstablished', 'domesticState', 'domesticStateStartingDate'],
122
118
  },
123
119
  NOT_ALIGNED_DATE_ESTABLISHED_CLOSE_DATE: {
124
120
  message: `Adjust the close date to be after the date established.`,
@@ -210,6 +206,7 @@ exports.VALIDATION_MESSAGES = {
210
206
  CLIENT_COULD_NOT_BE_DELETED_CONTACTS_EXIST: {
211
207
  message: `This client cannot be deleted because it has contacts associated`,
212
208
  },
209
+ //UPDATE-STATES-VALIDATIONS
213
210
  STATES_IDS_DOES_NOT_EXIST: {
214
211
  message: `States with ids '{ids}' do not exist`,
215
212
  params: ['ids'],
@@ -221,19 +218,15 @@ exports.VALIDATION_MESSAGES = {
221
218
  message: `States Starting Date cannot be Empty`,
222
219
  },
223
220
  NOT_ALIGNED_STATE_STARTING_ENDING_DATE: {
224
- message: `Domestic state starting date needs to be before the ending date`,
221
+ message: `State starting date needs to be before the ending date`,
225
222
  },
226
223
  NOT_ALIGNED_DATE_ESTABLISHED_STATES_STARTING_DATE: {
227
224
  message: `Adjust the start date to be on or after the client's date established, {clientStartDate}.`,
228
- params: [
229
- 'clientStartDate',
230
- ],
225
+ params: ['clientStartDate'],
231
226
  },
232
227
  NOT_ALIGNED_CLOSE_DATE_STATES_STARTING_DATE: {
233
228
  message: `Adjust the start date to be before the client's close date, {clientCloseDate}.`,
234
- params: [
235
- 'clientCloseDate',
236
- ],
229
+ params: ['clientCloseDate'],
237
230
  },
238
231
  DOMESTIC_STATES_DATE_GAP_DETECTED: {
239
232
  message: `There is a gap in the timeframes between {currentState}, ending {currentStateEndDate}, and {nextState}, starting {nextStateStartDate}. Please adjust the dates to fill this gap.`,
@@ -248,12 +241,94 @@ exports.VALIDATION_MESSAGES = {
248
241
  params: ['dateEstablished', 'earliestState', 'earliestStateStartDate'],
249
242
  },
250
243
  STATES_DATES_OVERLAP: {
251
- message: `There cannot be two {residence} states in the same timeframe. The state of {state} has a timeframe starting {stateStartDate} and ending {stateEndDate}. Please adjust the dates on the new or existing domestic state/s to avoid an overlap.`,
252
- params: ['state', 'stateStartDate', 'stateEndDate', 'residence'],
244
+ message: `There are multiple entries for {state} with overlapping timeframes: {state} from {startDate1} to {endDate1}, {state} from {startDate2} to {endDate2}. A state cannot appear more than once with overlapping dates, even if the residence type is different. Please adjust the dates on the new or existing {state} entries to remove the overlap.`,
245
+ params: ['state', 'startDate1', 'endDate1', 'startDate2', 'endDate2'],
253
246
  },
254
247
  ALL_NON_LAST_DOMESTIC_STATES_REQUIRE_ENDING_DATE: {
255
248
  message: `Only the last domestic state can be open without an end date. Add an ending date to the existing state before adding a start date for a new state.`,
256
249
  },
250
+ //UPDATE-ENTITY-TYPES-VALIDATIONS
251
+ ENTITY_TYPES_IDS_DOES_NOT_EXIST: {
252
+ message: `Entity types with ids '{ids}' do not exist`,
253
+ params: ['ids'],
254
+ },
255
+ AT_LEAST_ONE_ENTITY_TYPE_SHOULD_EXIST: {
256
+ message: `At least one entity type should exist`,
257
+ },
258
+ ENTITY_TYPES_STARTING_DATE_NOT_POPULATED: {
259
+ message: `Entity Type Starting Date cannot be Empty`,
260
+ },
261
+ NOT_ALIGNED_ENTITY_TYPES_STARTING_ENDING_DATE: {
262
+ message: `Entity type starting date needs to be before the ending date`,
263
+ },
264
+ NOT_ALIGNED_DATE_ESTABLISHED_ENTITY_TYPES_STARTING_DATE: {
265
+ message: `Adjust the start date to be on or after the client's date established, {clientStartDate}.`,
266
+ params: ['clientStartDate'],
267
+ },
268
+ NOT_ALIGNED_CLOSE_DATE_ENTITY_TYPES_STARTING_DATE: {
269
+ message: `Adjust the start date to be before the client's close date, {clientCloseDate}.`,
270
+ params: ['clientCloseDate'],
271
+ },
272
+ ENTITY_TYPES_DATE_GAP_DETECTED: {
273
+ message: `There is a gap in the timeframes between {currentEntityType}, ending {currentEntityTypeEndDate}, and {nextEntityType}, starting {nextEntityTypeStartDate}. Please adjust the dates to fill this gap.`,
274
+ params: ['currentEntityType', 'currentEntityTypeEndDate', 'nextEntityType', 'nextEntityTypeStartDate'],
275
+ },
276
+ ENTITY_TYPES_CONSECUTIVE_DUPLICATES_DETECTED: {
277
+ message: `There are two entries for {entityType} with timeframes that immediately follow each other. {entityType} ending {firstPeriodEnd}, and {entityType} starting {secondPeriodStart}. Please update one entry to include the entire timeframe for {entityType}. `,
278
+ params: ['entityType', 'firstPeriodStart', 'firstPeriodEnd', 'secondPeriodStart'],
279
+ },
280
+ ENTITY_TYPE_EARLIEST_AND_DATE_ESTABLISHED_GAP_DETECTED: {
281
+ message: `There is a gap between the client's date established ({dateEstablished}) and the start of its first entity type ({earliestEntityType} starting {earliestEntityTypeStartDate}). There must be an entity type that begins on {dateEstablished}.`,
282
+ params: ['dateEstablished', 'earliestEntityType', 'earliestEntityTypeStartDate'],
283
+ },
284
+ ENTITY_TYPES_DATES_OVERLAP: {
285
+ message: `There are multiple entries for {entityType} with overlapping timeframes: {entityType} from {startDate1} to {endDate1}, {entityType} from {startDate2} to {endDate2}. An entity type cannot appear more than once with overlapping dates. Please adjust the dates on the new or existing {entityType} entries to remove the overlap.`,
286
+ params: ['entityType', 'startDate1', 'endDate1', 'startDate2', 'endDate2'],
287
+ },
288
+ ALL_NON_LAST_ENTITY_TYPES_REQUIRE_ENDING_DATE: {
289
+ message: `Only the last entity type can be open without an end date. Add an ending date to the existing entity type before adding a start date for a new entity type.`,
290
+ },
291
+ //UPDATE-FILING-TYPES-VALIDATIONS
292
+ FILING_TYPES_IDS_DOES_NOT_EXIST: {
293
+ message: `Filing types with ids '{ids}' do not exist`,
294
+ params: ['ids'],
295
+ },
296
+ AT_LEAST_ONE_FILING_TYPE_SHOULD_EXIST: {
297
+ message: `At least one filing type should exist`,
298
+ },
299
+ FILING_TYPES_STARTING_DATE_NOT_POPULATED: {
300
+ message: `Filing Type Starting Date cannot be Empty`,
301
+ },
302
+ NOT_ALIGNED_FILING_TYPES_STARTING_ENDING_DATE: {
303
+ message: `Filing type starting date needs to be before the ending date`,
304
+ },
305
+ NOT_ALIGNED_DATE_ESTABLISHED_FILING_TYPES_STARTING_DATE: {
306
+ message: `Adjust the start date to be on or after the client's date established, {clientStartDate}.`,
307
+ params: ['clientStartDate'],
308
+ },
309
+ NOT_ALIGNED_CLOSE_DATE_FILING_TYPES_STARTING_DATE: {
310
+ message: `Adjust the start date to be before the client's close date, {clientCloseDate}.`,
311
+ params: ['clientCloseDate'],
312
+ },
313
+ FILING_TYPES_DATE_GAP_DETECTED: {
314
+ message: `There is a gap in the timeframes between {currentFilingType}, ending {currentFilingTypeEndDate}, and {nextFilingType}, starting {nextFilingTypeStartDate}. Please adjust the dates to fill this gap.`,
315
+ params: ['currentFilingType', 'currentFilingTypeEndDate', 'nextFilingType', 'nextFilingTypeStartDate'],
316
+ },
317
+ FILING_TYPES_CONSECUTIVE_DUPLICATES_DETECTED: {
318
+ message: `There are two entries for {filingType} with timeframes that immediately follow each other. {filingType} ending {firstPeriodEnd}, and {filingType} starting {secondPeriodStart}. Please update one entry to include the entire timeframe for {filingType}. `,
319
+ params: ['filingType', 'firstPeriodStart', 'firstPeriodEnd', 'secondPeriodStart'],
320
+ },
321
+ FILING_TYPE_EARLIEST_AND_DATE_ESTABLISHED_GAP_DETECTED: {
322
+ message: `There is a gap between the client's date established ({dateEstablished}) and the start of its first filing type ({earliestFilingType} starting {earliestFilingTypeStartDate}). There must be a filing type that begins on {dateEstablished}.`,
323
+ params: ['dateEstablished', 'earliestFilingType', 'earliestFilingTypeStartDate'],
324
+ },
325
+ FILING_TYPES_DATES_OVERLAP: {
326
+ message: `There are multiple entries for {filingType} with overlapping timeframes: {filingType} from {startDate1} to {endDate1}, {filingType} from {startDate2} to {endDate2}. A filing type cannot appear more than once with overlapping dates. Please adjust the dates on the new or existing {filingType} entries to remove the overlap.`,
327
+ params: ['filingType', 'startDate1', 'endDate1', 'startDate2', 'endDate2'],
328
+ },
329
+ ALL_NON_LAST_FILING_TYPES_REQUIRE_ENDING_DATE: {
330
+ message: `Only the last filing type can be open without an end date. Add an ending date to the existing filing type before adding a start date for a new filing type.`,
331
+ },
257
332
  },
258
333
  FILING_CATEGORY: {
259
334
  INVALID_REQUEST: {
package/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "@forwardslashns/taskit-validation-messages",
3
- "version": "1.0.24",
3
+ "version": "1.0.26",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "type": "commonjs",
7
7
  "scripts": {
8
8
  "build": "rimraf ./dist && tsc",
9
- "prepublishOnly": "npm run build"
9
+ "prepublishOnly": "npm run build",
10
+ "format:fix": "prettier --write --ignore-path .gitignore ."
10
11
  },
11
12
  "engines": {
12
13
  "node": ">=22.0.0"
@@ -20,7 +21,8 @@
20
21
  "devDependencies": {
21
22
  "@types/node": "^22.9.1",
22
23
  "rimraf": "^6.0.1",
23
- "typescript": "^5.8.2"
24
+ "typescript": "^5.8.2",
25
+ "prettier": "^3.5.3"
24
26
  },
25
27
  "repository": {
26
28
  "type": "git",
package/src/index.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { getValidationMessage } from "./validation/validation-message.formatter";
2
- import { VALIDATION_MESSAGES } from "./validation/validation-messages";
1
+ import { getValidationMessage } from './validation/validation-message.formatter';
2
+ import { VALIDATION_MESSAGES } from './validation/validation-messages';
3
3
 
4
4
  export { VALIDATION_MESSAGES, getValidationMessage };
@@ -2,10 +2,7 @@ import { VALIDATION_MESSAGES } from './validation-messages';
2
2
 
3
3
  type Features = keyof typeof VALIDATION_MESSAGES;
4
4
  type ErrorType<F extends Features> = keyof (typeof VALIDATION_MESSAGES)[F];
5
- type ErrorMessageParams<
6
- F extends Features,
7
- E extends ErrorType<F>,
8
- > = (typeof VALIDATION_MESSAGES)[F][E] extends {
5
+ type ErrorMessageParams<F extends Features, E extends ErrorType<F>> = (typeof VALIDATION_MESSAGES)[F][E] extends {
9
6
  params: infer P extends readonly string[];
10
7
  }
11
8
  ? P
@@ -16,17 +13,12 @@ type MessageConfig = {
16
13
  params?: readonly string[];
17
14
  };
18
15
 
19
- export const getValidationMessage = <
20
- FeatureType extends Features,
21
- FeatureErrorType extends ErrorType<FeatureType>,
22
- >(
16
+ export const getValidationMessage = <FeatureType extends Features, FeatureErrorType extends ErrorType<FeatureType>>(
23
17
  feature: FeatureType,
24
18
  featureError: FeatureErrorType,
25
19
  params?: MessageParams<ErrorMessageParams<FeatureType, FeatureErrorType>>
26
20
  ): string => {
27
- const messageConfig = VALIDATION_MESSAGES[feature][
28
- featureError
29
- ] as MessageConfig;
21
+ const messageConfig = VALIDATION_MESSAGES[feature][featureError] as MessageConfig;
30
22
 
31
23
  if (!messageConfig) {
32
24
  throw new Error(
@@ -37,20 +29,14 @@ export const getValidationMessage = <
37
29
  const inputParams = params || {};
38
30
  const errorSuffix = `for feature: ${String(feature)}, error: ${String(featureError)}`;
39
31
  let message = messageConfig.message;
40
- const expectedParams = messageConfig.params?.length
41
- ? messageConfig.params
42
- : [];
32
+ const expectedParams = messageConfig.params?.length ? messageConfig.params : [];
43
33
 
44
34
  if (!message) {
45
- throw new Error(
46
- `Validation error message is not defined properly in configuration ${errorSuffix}`
47
- );
35
+ throw new Error(`Validation error message is not defined properly in configuration ${errorSuffix}`);
48
36
  }
49
37
 
50
38
  if (params && !expectedParams.length) {
51
- throw new Error(
52
- `Validation error params are not defined properly in configuration ${errorSuffix}`
53
- );
39
+ throw new Error(`Validation error params are not defined properly in configuration ${errorSuffix}`);
54
40
  }
55
41
 
56
42
  expectedParams.forEach((param) => {
@@ -71,10 +57,7 @@ export const getValidationMessage = <
71
57
  }
72
58
 
73
59
  expectedParams.forEach((param) => {
74
- message = message.replaceAll(
75
- `{${param}}`,
76
- (inputParams as Record<string, string>)[param]
77
- );
60
+ message = message.replaceAll(`{${param}}`, (inputParams as Record<string, string>)[param]);
78
61
  });
79
62
 
80
63
  return message;
@@ -111,11 +111,7 @@ export const VALIDATION_MESSAGES = {
111
111
  },
112
112
  NOT_ALIGNED_DATE_ESTABLISHED_DOMESTIC_STATE_STARTING_DATE: {
113
113
  message: `The state, {domesticState}, starts on {domesticStateStartingDate}, which is earlier than the client's date established, {clientDateEstablished}. Please adjust the start date of the state or the client's date established.`,
114
- params: [
115
- 'clientDateEstablished',
116
- 'domesticState',
117
- 'domesticStateStartingDate',
118
- ],
114
+ params: ['clientDateEstablished', 'domesticState', 'domesticStateStartingDate'],
119
115
  },
120
116
  NOT_ALIGNED_DATE_ESTABLISHED_CLOSE_DATE: {
121
117
  message: `Adjust the close date to be after the date established.`,
@@ -207,6 +203,7 @@ export const VALIDATION_MESSAGES = {
207
203
  CLIENT_COULD_NOT_BE_DELETED_CONTACTS_EXIST: {
208
204
  message: `This client cannot be deleted because it has contacts associated`,
209
205
  },
206
+ //UPDATE-STATES-VALIDATIONS
210
207
  STATES_IDS_DOES_NOT_EXIST: {
211
208
  message: `States with ids '{ids}' do not exist`,
212
209
  params: ['ids'],
@@ -218,19 +215,15 @@ export const VALIDATION_MESSAGES = {
218
215
  message: `States Starting Date cannot be Empty`,
219
216
  },
220
217
  NOT_ALIGNED_STATE_STARTING_ENDING_DATE: {
221
- message: `Domestic state starting date needs to be before the ending date`,
218
+ message: `State starting date needs to be before the ending date`,
222
219
  },
223
220
  NOT_ALIGNED_DATE_ESTABLISHED_STATES_STARTING_DATE: {
224
221
  message: `Adjust the start date to be on or after the client's date established, {clientStartDate}.`,
225
- params: [
226
- 'clientStartDate',
227
- ],
222
+ params: ['clientStartDate'],
228
223
  },
229
224
  NOT_ALIGNED_CLOSE_DATE_STATES_STARTING_DATE: {
230
225
  message: `Adjust the start date to be before the client's close date, {clientCloseDate}.`,
231
- params: [
232
- 'clientCloseDate',
233
- ],
226
+ params: ['clientCloseDate'],
234
227
  },
235
228
  DOMESTIC_STATES_DATE_GAP_DETECTED: {
236
229
  message: `There is a gap in the timeframes between {currentState}, ending {currentStateEndDate}, and {nextState}, starting {nextStateStartDate}. Please adjust the dates to fill this gap.`,
@@ -245,12 +238,96 @@ export const VALIDATION_MESSAGES = {
245
238
  params: ['dateEstablished', 'earliestState', 'earliestStateStartDate'],
246
239
  },
247
240
  STATES_DATES_OVERLAP: {
248
- message: `There cannot be two {residence} states in the same timeframe. The state of {state} has a timeframe starting {stateStartDate} and ending {stateEndDate}. Please adjust the dates on the new or existing domestic state/s to avoid an overlap.`,
249
- params: ['state', 'stateStartDate', 'stateEndDate', 'residence'],
241
+ message: `There are multiple entries for {state} with overlapping timeframes: {state} from {startDate1} to {endDate1}, {state} from {startDate2} to {endDate2}. A state cannot appear more than once with overlapping dates, even if the residence type is different. Please adjust the dates on the new or existing {state} entries to remove the overlap.`,
242
+ params: ['state', 'startDate1', 'endDate1', 'startDate2', 'endDate2'],
250
243
  },
251
244
  ALL_NON_LAST_DOMESTIC_STATES_REQUIRE_ENDING_DATE: {
252
245
  message: `Only the last domestic state can be open without an end date. Add an ending date to the existing state before adding a start date for a new state.`,
253
246
  },
247
+
248
+ //UPDATE-ENTITY-TYPES-VALIDATIONS
249
+ ENTITY_TYPES_IDS_DOES_NOT_EXIST: {
250
+ message: `Entity types with ids '{ids}' do not exist`,
251
+ params: ['ids'],
252
+ },
253
+ AT_LEAST_ONE_ENTITY_TYPE_SHOULD_EXIST: {
254
+ message: `At least one entity type should exist`,
255
+ },
256
+ ENTITY_TYPES_STARTING_DATE_NOT_POPULATED: {
257
+ message: `Entity Type Starting Date cannot be Empty`,
258
+ },
259
+ NOT_ALIGNED_ENTITY_TYPES_STARTING_ENDING_DATE: {
260
+ message: `Entity type starting date needs to be before the ending date`,
261
+ },
262
+ NOT_ALIGNED_DATE_ESTABLISHED_ENTITY_TYPES_STARTING_DATE: {
263
+ message: `Adjust the start date to be on or after the client's date established, {clientStartDate}.`,
264
+ params: ['clientStartDate'],
265
+ },
266
+ NOT_ALIGNED_CLOSE_DATE_ENTITY_TYPES_STARTING_DATE: {
267
+ message: `Adjust the start date to be before the client's close date, {clientCloseDate}.`,
268
+ params: ['clientCloseDate'],
269
+ },
270
+ ENTITY_TYPES_DATE_GAP_DETECTED: {
271
+ message: `There is a gap in the timeframes between {currentEntityType}, ending {currentEntityTypeEndDate}, and {nextEntityType}, starting {nextEntityTypeStartDate}. Please adjust the dates to fill this gap.`,
272
+ params: ['currentEntityType', 'currentEntityTypeEndDate', 'nextEntityType', 'nextEntityTypeStartDate'],
273
+ },
274
+ ENTITY_TYPES_CONSECUTIVE_DUPLICATES_DETECTED: {
275
+ message: `There are two entries for {entityType} with timeframes that immediately follow each other. {entityType} ending {firstPeriodEnd}, and {entityType} starting {secondPeriodStart}. Please update one entry to include the entire timeframe for {entityType}. `,
276
+ params: ['entityType', 'firstPeriodStart', 'firstPeriodEnd', 'secondPeriodStart'],
277
+ },
278
+ ENTITY_TYPE_EARLIEST_AND_DATE_ESTABLISHED_GAP_DETECTED: {
279
+ message: `There is a gap between the client's date established ({dateEstablished}) and the start of its first entity type ({earliestEntityType} starting {earliestEntityTypeStartDate}). There must be an entity type that begins on {dateEstablished}.`,
280
+ params: ['dateEstablished', 'earliestEntityType', 'earliestEntityTypeStartDate'],
281
+ },
282
+ ENTITY_TYPES_DATES_OVERLAP: {
283
+ message: `There are multiple entries for {entityType} with overlapping timeframes: {entityType} from {startDate1} to {endDate1}, {entityType} from {startDate2} to {endDate2}. An entity type cannot appear more than once with overlapping dates. Please adjust the dates on the new or existing {entityType} entries to remove the overlap.`,
284
+ params: ['entityType', 'startDate1', 'endDate1', 'startDate2', 'endDate2'],
285
+ },
286
+ ALL_NON_LAST_ENTITY_TYPES_REQUIRE_ENDING_DATE: {
287
+ message: `Only the last entity type can be open without an end date. Add an ending date to the existing entity type before adding a start date for a new entity type.`,
288
+ },
289
+
290
+ //UPDATE-FILING-TYPES-VALIDATIONS
291
+ FILING_TYPES_IDS_DOES_NOT_EXIST: {
292
+ message: `Filing types with ids '{ids}' do not exist`,
293
+ params: ['ids'],
294
+ },
295
+ AT_LEAST_ONE_FILING_TYPE_SHOULD_EXIST: {
296
+ message: `At least one filing type should exist`,
297
+ },
298
+ FILING_TYPES_STARTING_DATE_NOT_POPULATED: {
299
+ message: `Filing Type Starting Date cannot be Empty`,
300
+ },
301
+ NOT_ALIGNED_FILING_TYPES_STARTING_ENDING_DATE: {
302
+ message: `Filing type starting date needs to be before the ending date`,
303
+ },
304
+ NOT_ALIGNED_DATE_ESTABLISHED_FILING_TYPES_STARTING_DATE: {
305
+ message: `Adjust the start date to be on or after the client's date established, {clientStartDate}.`,
306
+ params: ['clientStartDate'],
307
+ },
308
+ NOT_ALIGNED_CLOSE_DATE_FILING_TYPES_STARTING_DATE: {
309
+ message: `Adjust the start date to be before the client's close date, {clientCloseDate}.`,
310
+ params: ['clientCloseDate'],
311
+ },
312
+ FILING_TYPES_DATE_GAP_DETECTED: {
313
+ message: `There is a gap in the timeframes between {currentFilingType}, ending {currentFilingTypeEndDate}, and {nextFilingType}, starting {nextFilingTypeStartDate}. Please adjust the dates to fill this gap.`,
314
+ params: ['currentFilingType', 'currentFilingTypeEndDate', 'nextFilingType', 'nextFilingTypeStartDate'],
315
+ },
316
+ FILING_TYPES_CONSECUTIVE_DUPLICATES_DETECTED: {
317
+ message: `There are two entries for {filingType} with timeframes that immediately follow each other. {filingType} ending {firstPeriodEnd}, and {filingType} starting {secondPeriodStart}. Please update one entry to include the entire timeframe for {filingType}. `,
318
+ params: ['filingType', 'firstPeriodStart', 'firstPeriodEnd', 'secondPeriodStart'],
319
+ },
320
+ FILING_TYPE_EARLIEST_AND_DATE_ESTABLISHED_GAP_DETECTED: {
321
+ message: `There is a gap between the client's date established ({dateEstablished}) and the start of its first filing type ({earliestFilingType} starting {earliestFilingTypeStartDate}). There must be a filing type that begins on {dateEstablished}.`,
322
+ params: ['dateEstablished', 'earliestFilingType', 'earliestFilingTypeStartDate'],
323
+ },
324
+ FILING_TYPES_DATES_OVERLAP: {
325
+ message: `There are multiple entries for {filingType} with overlapping timeframes: {filingType} from {startDate1} to {endDate1}, {filingType} from {startDate2} to {endDate2}. A filing type cannot appear more than once with overlapping dates. Please adjust the dates on the new or existing {filingType} entries to remove the overlap.`,
326
+ params: ['filingType', 'startDate1', 'endDate1', 'startDate2', 'endDate2'],
327
+ },
328
+ ALL_NON_LAST_FILING_TYPES_REQUIRE_ENDING_DATE: {
329
+ message: `Only the last filing type can be open without an end date. Add an ending date to the existing filing type before adding a start date for a new filing type.`,
330
+ },
254
331
  },
255
332
  FILING_CATEGORY: {
256
333
  INVALID_REQUEST: {
@@ -318,7 +395,6 @@ export const VALIDATION_MESSAGES = {
318
395
  message: `Reset password link is no longer valid. Please use the most recent one.`,
319
396
  },
320
397
  },
321
-
322
398
  //BACKEND ONLY VALIDATION FEATURES
323
399
  DATA_FILTER: {
324
400
  MISSING_PAGE_SIZE: {