@e22m4u/js-repository 0.8.2 → 0.8.3

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/README.md CHANGED
@@ -483,14 +483,14 @@ dbs.defineModel({
483
483
  наоборот допускает дублирование пустых значений уникального свойства,
484
484
  поскольку они не участвуют в проверке.
485
485
 
486
- | тип | пустые значения |
487
- |-------------|---------------------------|
488
- | `'any'` | `undefined`, `null`, `''` |
489
- | `'string'` | `undefined`, `null`, `''` |
490
- | `'number'` | `undefined`, `null` |
491
- | `'boolean'` | `undefined`, `null` |
492
- | `'array'` | `undefined`, `null` |
493
- | `'object'` | `undefined`, `null` |
486
+ | константа | тип | пустые значения |
487
+ |--------------------|-------------|------------------------------|
488
+ | `DataType.ANY` | `"any"` | *пустые значения всех типов* |
489
+ | `DataType.STRING` | `"string"` | `undefined`, `null`, `""` |
490
+ | `DataType.NUMBER` | `"number"` | `undefined`, `null`, `0` |
491
+ | `DataType.BOOLEAN` | `"boolean"` | `undefined`, `null` |
492
+ | `DataType.ARRAY` | `"array"` | `undefined`, `null`, `[]` |
493
+ | `DataType.OBJECT` | `"object"` | `undefined`, `null`, `{}` |
494
494
 
495
495
  ### Переопределение пустых значений
496
496
 
@@ -526,8 +526,8 @@ class EmptyValuesService {
526
526
 
527
527
  **Пример**
528
528
 
529
- Если строковое свойство является обязательным, то значение `""` (пустая строка)
530
- приведет к ошибке. Следующий пример демонстрирует, как изменить данное
529
+ Если свойство с типом `string` является обязательным, то попытка записи пустой
530
+ строки приведет к ошибке. Следующий пример демонстрирует, как изменить данное
531
531
  поведение, оставив в качестве пустых значений только `undefined` и `null`.
532
532
 
533
533
  ```js
@@ -544,8 +544,9 @@ const emptyValuesService = dbs.getService(EmptyValuesService);
544
544
  emptyValuesService.setEmptyValuesOf(DataType.STRING, [undefined, null]);
545
545
  ```
546
546
 
547
- Теперь пустая строка будет успешно проходить проверку для свойств
548
- с типом `string`, а также не будет заменяться на значение по умолчанию.
547
+ Теперь пустая строка будет успешно проходить проверку для обязательных свойств
548
+ с типом `string`, а также не будет заменяться на значение по умолчанию
549
+ для необязательных свойств модели.
549
550
 
550
551
  ## Репозиторий
551
552
 
@@ -1881,7 +1881,7 @@ var init_model_definition_utils = __esm({
1881
1881
  const propDef = propDefs[propName];
1882
1882
  const propValue = extendedData[propName];
1883
1883
  const propType = propDef != null ? this.getDataTypeFromPropertyDefinition(propDef) : DataType.ANY;
1884
- const isEmpty = emptyValuesService.isEmptyByType(propType, propValue);
1884
+ const isEmpty = emptyValuesService.isEmptyOf(propType, propValue);
1885
1885
  if (!isEmpty) return;
1886
1886
  if (propDef && typeof propDef === "object" && propDef.default !== void 0) {
1887
1887
  extendedData[propName] = this.getDefaultPropertyValue(
@@ -2239,7 +2239,7 @@ var init_property_uniqueness_validator = __esm({
2239
2239
  const propValue = modelData[propName];
2240
2240
  if (propDef.unique === PropertyUniqueness.SPARSE) {
2241
2241
  const propType = propDef.type || DataType.ANY;
2242
- const isEmpty = emptyValuesService.isEmptyByType(propType, propValue);
2242
+ const isEmpty = emptyValuesService.isEmptyOf(propType, propValue);
2243
2243
  if (isEmpty) continue;
2244
2244
  }
2245
2245
  if (methodName === "create") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@e22m4u/js-repository",
3
- "version": "0.8.2",
3
+ "version": "0.8.3",
4
4
  "description": "Реализация репозитория для работы с базами данных",
5
5
  "author": "Mikhail Evstropov <e22m4u@yandex.ru>",
6
6
  "license": "MIT",
@@ -39,7 +39,7 @@
39
39
  "prepare": "husky"
40
40
  },
41
41
  "dependencies": {
42
- "@e22m4u/js-empty-values": "~0.3.1",
42
+ "@e22m4u/js-empty-values": "~0.3.2",
43
43
  "@e22m4u/js-format": "~0.3.2",
44
44
  "@e22m4u/js-service": "~0.5.1"
45
45
  },
@@ -147,7 +147,7 @@ export class ModelDefinitionUtils extends Service {
147
147
  propDef != null
148
148
  ? this.getDataTypeFromPropertyDefinition(propDef)
149
149
  : DataType.ANY;
150
- const isEmpty = emptyValuesService.isEmptyByType(propType, propValue);
150
+ const isEmpty = emptyValuesService.isEmptyOf(propType, propValue);
151
151
  if (!isEmpty) return;
152
152
  if (
153
153
  propDef &&
@@ -85,7 +85,7 @@ export class PropertyUniquenessValidator extends Service {
85
85
  const propValue = modelData[propName];
86
86
  if (propDef.unique === PropertyUniqueness.SPARSE) {
87
87
  const propType = propDef.type || DataType.ANY;
88
- const isEmpty = emptyValuesService.isEmptyByType(propType, propValue);
88
+ const isEmpty = emptyValuesService.isEmptyOf(propType, propValue);
89
89
  if (isEmpty) continue;
90
90
  }
91
91
  // create