mobiletto-orm-typedef-gen 2.1.56 → 2.1.59

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.
@@ -95,6 +95,7 @@ const defaultPrepareContext = (typeDef, ctx) => {
95
95
  }
96
96
  field.Name = capitalize(field.name);
97
97
  field.fullName = (ctx.name !== typeDef.typeName ? ctx.name + "_" : "") + field.name;
98
+ field.labelName = typeof field.label === "string" ? field.label : field.fullName;
98
99
  }
99
100
  ctx.fieldNamesArray = JSON.stringify(fieldNames);
100
101
  ctx.fieldParamsArray = fieldNames.join(",");
@@ -5,20 +5,20 @@ import * as yup from "yup";{{/if}}
5
5
 
6
6
  export const {{Name}}SchemaFields = {{{curlyOpen}}}{{#each fields}}
7
7
  {{name}}: {{#if typeIsObject}}{{ ../Name }}_{{name}}Schema{{else}}{{#if typeIsArray}}yup.array().of(yup.{{valueType}}{{else}}yup.{{type}}{{/if}}(){{#if typeIsString}}.trim().transform(v => v === '' ? undefined : v){{/if}}{{#if isEnum}}
8
- {{arrayIndent}}.oneOf({{{enumValues}}}, '{{fullName}}_enum'){{/if}}{{#if minValue}}
9
- {{arrayIndent}}.min({{minValue}}, '{{fullName}}_minValue'){{/if}}{{#if maxValue}}
10
- {{arrayIndent}}.max({{maxValue}}, '{{fullName}}_maxValue'){{/if}}{{#if min}}
11
- {{arrayIndent}}.min({{min}}, '{{fullName}}_min'){{/if}}{{#if max}}
12
- {{arrayIndent}}.max({{max}}, '{{fullName}}_max'){{/if}}{{#if regex}}
13
- {{arrayIndent}}.matches({{{regexValue}}}, '{{fullName}}_regex'){{/if}}
14
- {{arrayIndent}}.typeError('{{fullName}}_invalid'){{#if typeIsArray}})
15
- .typeError('{{fullName}}_invalid'){{/if}}{{/if}}{{#if required}}
16
- .required('{{fullName}}_required'){{else}}
8
+ {{arrayIndent}}.oneOf({{{enumValues}}}, '{{labelName}}_enum'){{/if}}{{#if minValue}}
9
+ {{arrayIndent}}.min({{minValue}}, '{{labelName}}_minValue'){{/if}}{{#if maxValue}}
10
+ {{arrayIndent}}.max({{maxValue}}, '{{labelName}}_maxValue'){{/if}}{{#if min}}
11
+ {{arrayIndent}}.min({{min}}, '{{labelName}}_min'){{/if}}{{#if max}}
12
+ {{arrayIndent}}.max({{max}}, '{{labelName}}_max'){{/if}}{{#if regex}}
13
+ {{arrayIndent}}.matches({{{regexValue}}}, '{{labelName}}_regex'){{/if}}
14
+ {{arrayIndent}}.typeError('{{labelName}}_invalid'){{#if typeIsArray}})
15
+ .typeError('{{labelName}}_invalid'){{/if}}{{/if}}{{#if required}}
16
+ .required('{{labelName}}_required'){{else}}
17
17
  .notRequired(){{/if}}{{#if default}}
18
18
  .default({{{defaultValue}}}){{/if}}{{#if test}}
19
19
  .test({
20
20
  name: "{{test.message}}",
21
- message: '{{fullName}}_{{test.message}}',
21
+ message: '{{labelName}}_{{test.message}}',
22
22
  skipAbsent: true,
23
23
  test(value{{#if ../typescript}}: string | number | boolean | null | undefined{{/if}}, ctx) {
24
24
  const t = {{{testCode}}};
@@ -31,7 +31,7 @@ export const {{Name}}SchemaFields = {{{curlyOpen}}}{{#each fields}}
31
31
  const v{{#if ../typescript}}: Record<string, unknown>{{/if}} = { {{whenFieldNames}} };
32
32
  return w(v);
33
33
  },
34
- then: (schema) => schema.required('{{fullName}}_required'),
34
+ then: (schema) => schema.required('{{labelName}}_required'),
35
35
  otherwise: (schema) => schema.notRequired(),
36
36
  }){{/if}},{{/each}}
37
37
  };
@@ -95,6 +95,7 @@ const defaultPrepareContext = (typeDef, ctx) => {
95
95
  }
96
96
  field.Name = capitalize(field.name);
97
97
  field.fullName = (ctx.name !== typeDef.typeName ? ctx.name + "_" : "") + field.name;
98
+ field.labelName = typeof field.label === "string" ? field.label : field.fullName;
98
99
  }
99
100
  ctx.fieldNamesArray = JSON.stringify(fieldNames);
100
101
  ctx.fieldParamsArray = fieldNames.join(",");
@@ -5,20 +5,20 @@ import * as yup from "yup";{{/if}}
5
5
 
6
6
  export const {{Name}}SchemaFields = {{{curlyOpen}}}{{#each fields}}
7
7
  {{name}}: {{#if typeIsObject}}{{ ../Name }}_{{name}}Schema{{else}}{{#if typeIsArray}}yup.array().of(yup.{{valueType}}{{else}}yup.{{type}}{{/if}}(){{#if typeIsString}}.trim().transform(v => v === '' ? undefined : v){{/if}}{{#if isEnum}}
8
- {{arrayIndent}}.oneOf({{{enumValues}}}, '{{fullName}}_enum'){{/if}}{{#if minValue}}
9
- {{arrayIndent}}.min({{minValue}}, '{{fullName}}_minValue'){{/if}}{{#if maxValue}}
10
- {{arrayIndent}}.max({{maxValue}}, '{{fullName}}_maxValue'){{/if}}{{#if min}}
11
- {{arrayIndent}}.min({{min}}, '{{fullName}}_min'){{/if}}{{#if max}}
12
- {{arrayIndent}}.max({{max}}, '{{fullName}}_max'){{/if}}{{#if regex}}
13
- {{arrayIndent}}.matches({{{regexValue}}}, '{{fullName}}_regex'){{/if}}
14
- {{arrayIndent}}.typeError('{{fullName}}_invalid'){{#if typeIsArray}})
15
- .typeError('{{fullName}}_invalid'){{/if}}{{/if}}{{#if required}}
16
- .required('{{fullName}}_required'){{else}}
8
+ {{arrayIndent}}.oneOf({{{enumValues}}}, '{{labelName}}_enum'){{/if}}{{#if minValue}}
9
+ {{arrayIndent}}.min({{minValue}}, '{{labelName}}_minValue'){{/if}}{{#if maxValue}}
10
+ {{arrayIndent}}.max({{maxValue}}, '{{labelName}}_maxValue'){{/if}}{{#if min}}
11
+ {{arrayIndent}}.min({{min}}, '{{labelName}}_min'){{/if}}{{#if max}}
12
+ {{arrayIndent}}.max({{max}}, '{{labelName}}_max'){{/if}}{{#if regex}}
13
+ {{arrayIndent}}.matches({{{regexValue}}}, '{{labelName}}_regex'){{/if}}
14
+ {{arrayIndent}}.typeError('{{labelName}}_invalid'){{#if typeIsArray}})
15
+ .typeError('{{labelName}}_invalid'){{/if}}{{/if}}{{#if required}}
16
+ .required('{{labelName}}_required'){{else}}
17
17
  .notRequired(){{/if}}{{#if default}}
18
18
  .default({{{defaultValue}}}){{/if}}{{#if test}}
19
19
  .test({
20
20
  name: "{{test.message}}",
21
- message: '{{fullName}}_{{test.message}}',
21
+ message: '{{labelName}}_{{test.message}}',
22
22
  skipAbsent: true,
23
23
  test(value{{#if ../typescript}}: string | number | boolean | null | undefined{{/if}}, ctx) {
24
24
  const t = {{{testCode}}};
@@ -31,7 +31,7 @@ export const {{Name}}SchemaFields = {{{curlyOpen}}}{{#each fields}}
31
31
  const v{{#if ../typescript}}: Record<string, unknown>{{/if}} = { {{whenFieldNames}} };
32
32
  return w(v);
33
33
  },
34
- then: (schema) => schema.required('{{fullName}}_required'),
34
+ then: (schema) => schema.required('{{labelName}}_required'),
35
35
  otherwise: (schema) => schema.notRequired(),
36
36
  }){{/if}},{{/each}}
37
37
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mobiletto-orm-typedef-gen",
3
- "version": "2.1.56",
3
+ "version": "2.1.59",
4
4
  "type": "module",
5
5
  "description": "generate various files based on mobiletto-orm-typedef definitions",
6
6
  "keywords": [
@@ -52,7 +52,7 @@
52
52
  "eslint": "^8.44.0",
53
53
  "eslint-config-prettier": "^8.8.0",
54
54
  "handlebars": "^4.7.7",
55
- "mobiletto-orm-typedef": "^2.2.11",
55
+ "mobiletto-orm-typedef": "^2.2.12",
56
56
  "mocha": "^10.2.0",
57
57
  "prettier": "^3.0.0",
58
58
  "tslint-config-prettier": "^1.18.0",