@bedrockio/model 0.7.2 → 0.7.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.
@@ -40,7 +40,7 @@ A 24 character hexadecimal string representing a Mongo [ObjectId](https://bit.ly
40
40
  An object with an \`id\` field may also be passed, which will be converted into a string.
41
41
  `.trim()
42
42
  });
43
- const namedSchemas = {
43
+ const NAMED_SCHEMAS = {
44
44
  // Email is special as we are assuming that in
45
45
  // all cases lowercase should be allowed but coerced.
46
46
  email: _yada.default.string().lowercase().email(),
@@ -61,6 +61,8 @@ const namedSchemas = {
61
61
  locale: _yada.default.string().locale(),
62
62
  md5: _yada.default.string().md5(),
63
63
  phone: _yada.default.string().phone(),
64
+ 'phone:US': _yada.default.string().phone('US'),
65
+ 'phone:NANP': _yada.default.string().phone('NANP'),
64
66
  postalCode: _yada.default.string().postalCode(),
65
67
  zipcode: _yada.default.string().zipcode(),
66
68
  sha1: _yada.default.string().sha1(),
@@ -70,7 +72,7 @@ const namedSchemas = {
70
72
  uuid: _yada.default.string().uuid()
71
73
  };
72
74
  function addValidators(schemas) {
73
- Object.assign(namedSchemas, schemas);
75
+ Object.assign(NAMED_SCHEMAS, schemas);
74
76
  }
75
77
  function applyValidation(schema, definition) {
76
78
  const hasUnique = (0, _softDelete.hasUniqueConstraints)(schema);
@@ -555,7 +557,7 @@ function wrapMongooseValidator(validator) {
555
557
  };
556
558
  }
557
559
  function getNamedSchema(name) {
558
- const schema = namedSchemas[name];
560
+ const schema = NAMED_SCHEMAS[name];
559
561
  if (!schema) {
560
562
  throw new Error(`Cannot find schema for "${name}".`);
561
563
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bedrockio/model",
3
- "version": "0.7.2",
3
+ "version": "0.7.3",
4
4
  "description": "Bedrock utilities for model creation.",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -30,7 +30,7 @@
30
30
  "lodash": "^4.17.21"
31
31
  },
32
32
  "peerDependencies": {
33
- "@bedrockio/yada": "^1.2.2",
33
+ "@bedrockio/yada": "^1.2.3",
34
34
  "mongoose": "^8.6.2"
35
35
  },
36
36
  "devDependencies": {
@@ -38,7 +38,7 @@
38
38
  "@babel/core": "^7.20.12",
39
39
  "@babel/preset-env": "^7.20.2",
40
40
  "@bedrockio/prettier-config": "^1.0.2",
41
- "@bedrockio/yada": "^1.2.2",
41
+ "@bedrockio/yada": "^1.2.3",
42
42
  "@shelf/jest-mongodb": "^4.3.2",
43
43
  "eslint": "^8.33.0",
44
44
  "eslint-plugin-bedrock": "^1.0.26",
package/src/validation.js CHANGED
@@ -49,7 +49,7 @@ An object with an \`id\` field may also be passed, which will be converted into
49
49
  `.trim(),
50
50
  });
51
51
 
52
- const namedSchemas = {
52
+ const NAMED_SCHEMAS = {
53
53
  // Email is special as we are assuming that in
54
54
  // all cases lowercase should be allowed but coerced.
55
55
  email: yd.string().lowercase().email(),
@@ -71,6 +71,8 @@ const namedSchemas = {
71
71
  locale: yd.string().locale(),
72
72
  md5: yd.string().md5(),
73
73
  phone: yd.string().phone(),
74
+ 'phone:US': yd.string().phone('US'),
75
+ 'phone:NANP': yd.string().phone('NANP'),
74
76
  postalCode: yd.string().postalCode(),
75
77
  zipcode: yd.string().zipcode(),
76
78
  sha1: yd.string().sha1(),
@@ -81,7 +83,7 @@ const namedSchemas = {
81
83
  };
82
84
 
83
85
  export function addValidators(schemas) {
84
- Object.assign(namedSchemas, schemas);
86
+ Object.assign(NAMED_SCHEMAS, schemas);
85
87
  }
86
88
 
87
89
  export function applyValidation(schema, definition) {
@@ -611,7 +613,7 @@ function wrapMongooseValidator(validator) {
611
613
  }
612
614
 
613
615
  function getNamedSchema(name) {
614
- const schema = namedSchemas[name];
616
+ const schema = NAMED_SCHEMAS[name];
615
617
  if (!schema) {
616
618
  throw new Error(`Cannot find schema for "${name}".`);
617
619
  }
@@ -19,7 +19,7 @@ export const OBJECT_ID_SCHEMA: {
19
19
  uppercase(assert?: boolean): any;
20
20
  match(reg: RegExp): any;
21
21
  email(): any;
22
- phone(): any;
22
+ phone(code: any): any;
23
23
  hex(): any;
24
24
  md5(): any;
25
25
  sha1(): any;
@@ -1 +1 @@
1
- {"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../src/validation.js"],"names":[],"mappings":"AAkFA,kDAEC;AAED,oEAgGC;AAsBD,wEA2BC;AAkVD;;;EAEC;AAED;;;EAOC;AAljBD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAQK"}
1
+ {"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../src/validation.js"],"names":[],"mappings":"AAoFA,kDAEC;AAED,oEAgGC;AAsBD,wEA2BC;AAkVD;;;EAEC;AAED;;;EAOC;AApjBD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAQK"}