@dwtechs/antity 0.12.0 → 0.13.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.
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
  [![License: MIT](https://img.shields.io/npm/l/@dwtechs/antity.svg?color=brightgreen)](https://opensource.org/licenses/MIT)
3
3
  [![npm version](https://badge.fury.io/js/%40dwtechs%2Fantity.svg)](https://www.npmjs.com/package/@dwtechs/antity)
4
4
  [![last version release date](https://img.shields.io/github/release-date/DWTechs/Antity.js)](https://www.npmjs.com/package/@dwtechs/antity)
5
- ![Jest:coverage](https://img.shields.io/badge/Jest:coverage-100%25-brightgreen.svg)
5
+ ![Jest:coverage](https://img.shields.io/badge/Jest:coverage-72%25-brightgreen.svg)
6
6
 
7
7
  - [Synopsis](#synopsis)
8
8
  - [Support](#support)
@@ -364,15 +364,15 @@ Any of these can be passed into the options object for each function.
364
364
  | type | Type | Type of the property |
365
365
  | min | number \| Date | Minimum value | 0 \| 1900-01-01
366
366
  | max | number \| Date | Maximum value | 999999999 \| 2200-12-31
367
- | required | boolean | Is this property required on insert | false
368
- | safe | boolean | Is this property safe to send to the client | true
369
- | typeCheck | boolean | Type is checked if true | false
370
- | methods | Method[] | SQL DML operations concerned by the property | [ "select", "insert", "update", "merge", "delete" ]
367
+ | required | boolean | Property is required during validation | false
368
+ | safe | boolean | Property is sent in the response | true
369
+ | typeCheck | boolean | Type is checked during validation | false
370
+ | methods | Method[] | property is validated for the listed methods only | [ "GET", "POST", "PUT", "DELETE" ]
371
371
  | sanitize | boolean | Sanitize the property if true | true
372
372
  | normalize | boolean | Normalize the property if true | false
373
373
  | validate | boolean | validate the property if true | true
374
- | sanitizer | ((v:any) => any) \| null | Sanitizer function if sanitize is true | null
375
- | normalizer | ((v:any) => any) \| null | Normalizer function if normalize is true | null
374
+ | sanitizer | ((v:any) => any) \| null | Custom sanitizer function if sanitize is true | null
375
+ | normalizer | ((v:any) => any) \| null | Custop Normalizer function if normalize is true | null
376
376
  | validator | ((v:any, min:number, max:number, typeCheck:boolean) => any) \| null | validator function if validate is true | null
377
377
 
378
378
  * *Min and max parameters are not used for boolean type*
package/dist/antity.d.ts CHANGED
@@ -74,6 +74,7 @@ declare class Entity {
74
74
  }
75
75
 
76
76
  declare class Property {
77
+ [key: string]: unknown;
77
78
  key: string;
78
79
  type: Type;
79
80
  min: number | Date | null;
package/dist/antity.js CHANGED
@@ -348,6 +348,7 @@ class Entity {
348
348
  this._unsafeProps = [];
349
349
  for (const p of properties) {
350
350
  const prop = new Property(p.key, p.type, p.min, p.max, p.required, p.safe, p.typeCheck, p.methods, p.sanitize, p.normalize, p.validate, p.sanitizer, p.normalizer, p.validator);
351
+ Object.assign(prop, p);
351
352
  this._properties.push(prop);
352
353
  if (!prop.safe)
353
354
  this._unsafeProps.push(prop.key);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dwtechs/antity",
3
- "version": "0.12.0",
3
+ "version": "0.13.0",
4
4
  "description": "Open source library for easy entity management",
5
5
  "keywords": [
6
6
  "entities"