validno 0.3.1 → 0.3.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/dist/dev.js CHANGED
@@ -1,23 +1,12 @@
1
1
  import Schema from './index.js';
2
- const userSchema = new Schema({
3
- name: {
4
- type: String,
5
- required: true
6
- },
7
- email: {
8
- type: String,
9
- required: true,
10
- rules: {
11
- isEmail: true
12
- }
13
- },
14
- age: {
15
- type: Number,
16
- required: false
2
+ const schema = new Schema({
3
+ query: { type: Object },
4
+ data: { type: Object },
5
+ params: {
6
+ upsert: { type: Boolean, required: false },
17
7
  }
18
8
  });
19
- const newUser = {
20
- name: "Barney",
21
- email: "barney@himym.com",
22
- };
23
- const result = userSchema.validate(newUser, 'age');
9
+ console.log(schema.validate({
10
+ query: {},
11
+ data: {}
12
+ }));
@@ -8,20 +8,19 @@ function validateKeyValue(params) {
8
8
  if (hasMissing) {
9
9
  return this.handleMissingKeyValidation({ results, key, nestedKey, data, reqs, missedCheck });
10
10
  }
11
- this.validateType({ results, key, value: data[key], reqs, nestedKey, typeChecked });
12
- this.validateRules({ results, nestedKey, value: data[key], reqs, data, rulesChecked });
11
+ const keyValue = data ? data[key] : undefined;
12
+ this.validateType({ results, key, value: keyValue, reqs, nestedKey, typeChecked });
13
+ this.validateRules({ results, nestedKey, value: keyValue, reqs, data, rulesChecked });
13
14
  return this.finishValidation({ results, nestedKey, missedCheck, typeChecked, rulesChecked });
14
15
  }
15
16
  function validateKey(input) {
16
- let { results, key, nestedKey, data, reqs } = input;
17
+ let { results, key, nestedKey = key, data, reqs } = input;
17
18
  if (data === undefined) {
18
19
  const noDataResult = new ValidnoResult();
19
20
  noDataResult.setNoData(nestedKey);
20
21
  }
21
22
  if (!results)
22
23
  results = new ValidnoResult();
23
- if (!nestedKey)
24
- nestedKey = key;
25
24
  const hasMissing = _helpers.hasMissing(input);
26
25
  if (_helpers.checkNestedIsMissing(reqs, data)) {
27
26
  return this.handleMissingNestedKey(nestedKey, results);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "validno",
3
- "version": "0.3.1",
4
- "description": "",
3
+ "version": "0.3.3",
4
+ "description": "A lightweight TypeScript validation library for runtime data validation.",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
7
7
  "tsc": "tsc -b src/",