@fincity/kirun-js 2.14.0 → 2.15.0

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.
@@ -132,9 +132,7 @@ test('Concatenate test 5', async () => {
132
132
  .setSteps(new Map([]))
133
133
  .setContext(new Map([]));
134
134
 
135
- await expect(add.execute(fep)).rejects.toThrow(
136
- 'Value undefined is not of valid type(s)\nExpected an array but found null',
137
- );
135
+ await expect(add.execute(fep)).rejects.toThrow("Error while executing the function System.Array.Concatenate's parameter secondSource with step name 'Unknown Step' with error : Expected an array but found null");
138
136
  // await expect(add.execute(fep)).rejects.toThrowError(
139
137
  // new SchemaValidationException(Schema.ofString("source"),'Value undefined is not of valid type(s)\nExpected an array but found null', );
140
138
  });
@@ -43,9 +43,8 @@ describe('From Now', () => {
43
43
 
44
44
  const result = await new FromNow().execute(fep);
45
45
 
46
- expect(result.allResults()[0].getResult().get(AbstractDateFunction.EVENT_RESULT_NAME)).toBe(
47
- 'in 20 mo',
48
- );
46
+ const retValue = result.allResults()[0].getResult().get(AbstractDateFunction.EVENT_RESULT_NAME);
47
+ expect(retValue == 'in 20 mo' || retValue == 'in 20 mo.').toBe(true);
49
48
  });
50
49
 
51
50
  test('should return the relative date with locale', async () => {
@@ -61,6 +61,6 @@ describe('ToDateString', () => {
61
61
  .allResults()[0]
62
62
  .getResult()
63
63
  .get(AbstractDateFunction.EVENT_RESULT_NAME);
64
- expect(result).toBe('1 January 2024');
64
+ expect(result == '1 January 2024' || result == 'January 1, 2024').toBeTruthy();
65
65
  });
66
66
  });
@@ -0,0 +1,16 @@
1
+ import { Schema, SchemaValidator } from '../../../../../src';
2
+
3
+ test('Check for valid Custom Messages in Numerical values', async () => {
4
+ let schema = Schema.from({
5
+ type: 'INTEGER',
6
+ minimum: 10,
7
+ details: {
8
+ validationMessages: {
9
+ "minimum": "Minimum value is 10",
10
+ }
11
+ }
12
+ });
13
+
14
+ expect(async () => SchemaValidator.validate([], schema!, undefined, -23))
15
+ .rejects.toThrowError("Minimum value is 10");
16
+ });
@@ -20,7 +20,7 @@ test('Schema Validator Test 1', async () => {
20
20
  expect(await SchemaValidator.validate([], objSchema, repo, obj)).toBe(obj);
21
21
 
22
22
  expect(SchemaValidator.validate([], objSchema, repo, { name: 123 })).rejects.toThrow(
23
- 'Value {"name":123} is not of valid type(s)\nValue 123 is not of valid type(s)\n123 is not String',
23
+ '123 is not String',
24
24
  );
25
25
 
26
26
  // expect(await SchemaValidator.validate([], schema, repo, 2.5)).toThrowError(new SchemaValidationException('', '2.5 is not a number of type Integer'));
@@ -28,8 +28,6 @@ test('Schema Validator fail with date test', async () => {
28
28
  expect(SchemaValidator.validate([], objSchema, repo, obj)).rejects.toThrow('date is mandatory');
29
29
  const dateObj = { name: 'surendhar.s', date: '1999-13-12' };
30
30
  const errorMsg =
31
- 'Value {"name":"surendhar.s","date":"1999-13-12"} is not of valid type(s)' +
32
- '\n' +
33
31
  'Type is missing in schema for declared DATE format.';
34
32
 
35
33
  expect(SchemaValidator.validate([], objSchema, repo, dateObj)).rejects.toThrow(errorMsg);
@@ -77,7 +75,7 @@ test('Schema Validator fail with time string type missing test ', async () => {
77
75
  const timeObj = { intSchema: 95, time: '22:23:61', name: 's.surendhar' };
78
76
 
79
77
  const errMsg =
80
- 'Value {"intSchema":95,"time":"22:23:61","name":"s.surendhar"} is not of valid type(s)\n' +
78
+
81
79
  'Type is missing in schema for declared TIME format.';
82
80
 
83
81
  expect(SchemaValidator.validate([], objSchema, repo, timeObj)).rejects.toThrow(errMsg);
@@ -107,8 +105,7 @@ test('Schema Validator fail with time test ', async () => {
107
105
  const timeObj = { intSchema: 95, time: '22:23:61', name: 's.surendhar' };
108
106
 
109
107
  const errMsg =
110
- 'Value {"intSchema":95,"time":"22:23:61","name":"s.surendhar"} is not of valid type(s)\n' +
111
- 'Value "22:23:61" is not of valid type(s)\n' +
108
+
112
109
  '22:23:61 is not matched with the time pattern';
113
110
 
114
111
  expect(SchemaValidator.validate([], objSchema, repo, timeObj)).rejects.toThrow(errMsg);
@@ -156,7 +153,7 @@ test('Schema Validator fail with email string type missing test ', async () => {
156
153
  const emailObj = { intSchema: 95, email: 'iosdjfdf123--@gmail.com', name: 's.surendhar' };
157
154
 
158
155
  const errMsg =
159
- 'Value {"intSchema":95,"email":"iosdjfdf123--@gmail.com","name":"s.surendhar"} is not of valid type(s)\n' +
156
+
160
157
  'Type is missing in schema for declared EMAIL format.';
161
158
 
162
159
  expect(SchemaValidator.validate([], objSchema, repo, emailObj)).rejects.toThrow(errMsg);
@@ -186,8 +183,7 @@ test('Schema Validator fail with email test ', async () => {
186
183
  const emailObj = { intSchema: 0, email: 'asdasdf@@*.com' };
187
184
 
188
185
  const errMsg =
189
- 'Value {"intSchema":0,"email":"asdasdf@@*.com"} is not of valid type(s)\n' +
190
- 'Value "asdasdf@@*.com" is not of valid type(s)\n' +
186
+
191
187
  'asdasdf@@*.com is not matched with the email pattern';
192
188
 
193
189
  expect(SchemaValidator.validate([], objSchema, repo, emailObj)).rejects.toThrow(errMsg);
@@ -232,7 +228,7 @@ test('Schema Validator fail with dateTime string type missing test ', async () =
232
228
  const emailObj = { intSchema: 95, dateTime: '2023-08-21T07:56:45+12:12', name: 's.surendhar' };
233
229
 
234
230
  const errMsg =
235
- 'Value {"intSchema":95,"dateTime":"2023-08-21T07:56:45+12:12","name":"s.surendhar"} is not of valid type(s)\n' +
231
+
236
232
  'Type is missing in schema for declared DATETIME format.';
237
233
 
238
234
  expect(SchemaValidator.validate([], objSchema, repo, emailObj)).rejects.toThrow(errMsg);
@@ -262,8 +258,7 @@ test('Schema Validator fail with dateTime test ', async () => {
262
258
  const dateTimeObj = { dateTime: '2023-08-221T07:56:45+12:12' };
263
259
 
264
260
  const errMsg =
265
- 'Value {"dateTime":"2023-08-221T07:56:45+12:12"} is not of valid type(s)\n' +
266
- 'Value "2023-08-221T07:56:45+12:12" is not of valid type(s)\n' +
261
+
267
262
  '2023-08-221T07:56:45+12:12 is not matched with the date time pattern';
268
263
 
269
264
  expect(SchemaValidator.validate([], objSchema, repo, dateTimeObj)).rejects.toThrow(errMsg);
@@ -1,4 +1,4 @@
1
- import { Schema, SchemaType, StringFormat, TypeUtil } from '../../../../../src';
1
+ import { Schema, SchemaType, SchemaValidator, StringFormat, TypeUtil } from '../../../../../src';
2
2
  import { StringValidator } from '../../../../../src';
3
3
 
4
4
  test('String valid case', async () => {
@@ -123,3 +123,19 @@ test('String email valid case', async () => {
123
123
 
124
124
  expect(StringValidator.validate([], schema, value)).toBe(value);
125
125
  });
126
+
127
+
128
+ test('String custom message', async () => {
129
+ const schema = Schema.from({
130
+ type: "STRING",
131
+ minLength: 10,
132
+ details: {
133
+ validationMessages: {
134
+ minLength: "You must enter something with minimum of ten characters"
135
+ }
136
+ }
137
+ })
138
+
139
+ expect(async () => SchemaValidator.validate([], schema!, undefined, "asdf"))
140
+ .rejects.toThrowError("You must enter something with minimum of ten characters");
141
+ });