structured-fw 1.0.0 → 1.0.2

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.
@@ -89,17 +89,19 @@ export class Component extends EventEmitter {
89
89
  return;
90
90
  }
91
91
  const importedParentData = this.parent ? this.importedParentData(this.parent.data) : {};
92
+ const dataServerSidePart = (this.entry && this.entry.module ?
93
+ await this.entry.module.getData(Object.assign(importedParentData, this.attributes, data || {}), this.document.ctx, this.document.application, this) : {}) || {};
92
94
  if (data === undefined) {
93
95
  if (this.entry && this.entry.module) {
94
- this.data = Object.assign(this.data, await this.entry.module.getData(Object.assign(importedParentData, this.attributes), this.document.ctx, this.document.application, this) || {});
96
+ this.data = Object.assign(this.data, dataServerSidePart);
95
97
  }
96
98
  else {
97
99
  this.attributes = Object.assign(importedParentData, this.attributes);
98
- this.data = Object.assign(exportedContextData, this.attributes);
100
+ this.data = Object.assign(this.data, this.attributes);
99
101
  }
100
102
  }
101
103
  else {
102
- this.data = Object.assign(exportedContextData, Object.assign(importedParentData, data), this.attributes);
104
+ this.data = Object.assign(this.data, Object.assign(importedParentData, data), this.attributes, dataServerSidePart);
103
105
  }
104
106
  this.fillData(this.data);
105
107
  if (this.entry === null || this.entry.exportData) {
@@ -2,6 +2,7 @@ import { FormValidationEntry, PostedDataDecoded, ValidationResult, ValidationRul
2
2
  export declare class FormValidation {
3
3
  fieldRules: Array<FormValidationEntry>;
4
4
  singleError: boolean;
5
+ customValidators: Array<string>;
5
6
  validators: {
6
7
  [name: string]: ValidatorFunction;
7
8
  };
@@ -2,6 +2,7 @@ export class FormValidation {
2
2
  constructor() {
3
3
  this.fieldRules = [];
4
4
  this.singleError = false;
5
+ this.customValidators = [];
5
6
  this.validators = {
6
7
  'required': async (data, field) => {
7
8
  if (!(field in data)) {
@@ -124,6 +125,7 @@ export class FormValidation {
124
125
  if (typeof decorator === 'function') {
125
126
  this.decorators[name] = decorator;
126
127
  }
128
+ this.customValidators.push(name);
127
129
  }
128
130
  registerDecorator(name, decorator) {
129
131
  this.decorators[name] = decorator;
@@ -138,7 +140,10 @@ export class FormValidation {
138
140
  const isRequired = entry.rules.includes('required');
139
141
  const value = data[entry.field[0]];
140
142
  const possiblyValidDataExists = typeof value === 'string';
141
- const isContent = !isRequired && (!possiblyValidDataExists || value.trim().length === 0);
143
+ const usesCustomValidators = this.fieldRules[i].rules.some((rule) => {
144
+ return this.customValidators.includes(rule);
145
+ });
146
+ const isContent = !usesCustomValidators && !isRequired && (!possiblyValidDataExists || value.trim().length === 0);
142
147
  if (!isContent) {
143
148
  for (let j = 0; j < entry.rules.length; j++) {
144
149
  const rule = entry.rules[j];
package/package.json CHANGED
@@ -19,7 +19,7 @@
19
19
  "license": "MIT",
20
20
  "type": "module",
21
21
  "main": "build/index",
22
- "version": "1.0.0",
22
+ "version": "1.0.2",
23
23
  "scripts": {
24
24
  "develop": "tsc --watch",
25
25
  "startDev": "cd build && nodemon --watch '../app/**/*' --watch '../build/**/*' -e js,html,css index.js",
@@ -36,8 +36,7 @@
36
36
  },
37
37
  "dependencies": {
38
38
  "handlebars": "^4.7.8",
39
- "mime-types": "^3.0.0",
40
- "ts-md5": "^1.3.1"
39
+ "mime-types": "^3.0.0"
41
40
  },
42
41
  "files": [
43
42
  "build/system/*",