@carecard/validate 3.27.0 → 3.28.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.
|
@@ -101,6 +101,9 @@ depend on those folders being present.
|
|
|
101
101
|
- Keep key-based property sanitization in `lib/validateProperties.js`.
|
|
102
102
|
- Keep whitelist, nested-path, casing, flattening, and CareCard bad-input
|
|
103
103
|
behavior in `lib/validateWhitelistProperties.js`.
|
|
104
|
+
- Import shared casing and bad-input behavior through the focused
|
|
105
|
+
`@carecard/common-util/case-converter` and `@carecard/common-util/errors`
|
|
106
|
+
entrypoints so the package root remains safe for browser bundles.
|
|
104
107
|
- Preserve the package's CommonJS module style unless the repository is
|
|
105
108
|
intentionally migrated.
|
|
106
109
|
- Keep the deprecated `validate` namespace export backward-compatible while
|
|
@@ -124,7 +127,8 @@ depend on those folders being present.
|
|
|
124
127
|
- `validateProperties` should return a new sanitized object and omit unknown or
|
|
125
128
|
invalid fields without mutating the input.
|
|
126
129
|
- `validateWhitelistProperties` should reject missing or invalid required fields
|
|
127
|
-
with CareCard `BAD_INPUT` errors through
|
|
130
|
+
with CareCard `BAD_INPUT` errors through the focused
|
|
131
|
+
`@carecard/common-util/errors` entrypoint.
|
|
128
132
|
- Optional whitelist fields should be ignored when absent and rejected when
|
|
129
133
|
present but invalid.
|
|
130
134
|
- Preserve supported snake_case and camelCase field aliases unless a task
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const {
|
|
4
|
-
error: { throwBadInputError },
|
|
5
|
-
} = require('@carecard/common-util');
|
|
3
|
+
const { throwBadInputError } = require('@carecard/common-util/errors');
|
|
6
4
|
const { isUserRoleRequestRoleString } = require('./validate');
|
|
7
5
|
|
|
8
6
|
const DEFAULT_USER_ROLE_REQUEST_ROLE = 'student';
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const {
|
|
4
|
-
|
|
5
|
-
caseConverter: { keysToSnakeCase },
|
|
6
|
-
} = require('@carecard/common-util');
|
|
3
|
+
const { keysToSnakeCase } = require('@carecard/common-util/case-converter');
|
|
4
|
+
const { throwBadInputError } = require('@carecard/common-util/errors');
|
|
7
5
|
|
|
8
6
|
const { validateProperties } = require('./validateProperties');
|
|
9
7
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@carecard/validate",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.28.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/CareCard-ca/pkg-validate.git"
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"typescript": "6.0.3"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@carecard/common-util": "3.
|
|
50
|
+
"@carecard/common-util": "3.28.0"
|
|
51
51
|
},
|
|
52
52
|
"nyc": {
|
|
53
53
|
"all": true,
|
package/readme.md
CHANGED
|
@@ -54,6 +54,11 @@ General validators are available both as top-level exports and under the
|
|
|
54
54
|
deprecated `validate` namespace. `validatePassword` is intentionally available
|
|
55
55
|
only as one direct export.
|
|
56
56
|
|
|
57
|
+
The package root is safe to import from browser bundles. Its whitelist and role
|
|
58
|
+
request validators use the focused `@carecard/common-util/case-converter` and
|
|
59
|
+
`@carecard/common-util/errors` entrypoints, so importing `isEmailString` does
|
|
60
|
+
not load server-only request context or trace storage.
|
|
61
|
+
|
|
57
62
|
```js
|
|
58
63
|
isEmailString('jane@example.com'); // true
|
|
59
64
|
validate.isEmailString('jane@example.com'); // true
|
|
@@ -204,12 +209,12 @@ await validateWhitelistProperties(input, ['user.first_name', 'user.contact.email
|
|
|
204
209
|
|
|
205
210
|
### Options
|
|
206
211
|
|
|
207
|
-
| Option | Default | Behavior
|
|
208
|
-
| -------------------- | -------- |
|
|
209
|
-
| `optionalProperties` | `[]` | Additional property paths that may be present. Absent optional paths are ignored. Present optional paths must be valid.
|
|
210
|
-
| `convertToSnakeCase` | `false` | When `true`, converts returned keys, including nested keys, to snake_case using `@carecard/common-util
|
|
211
|
-
| `flattenOutput` | `false` | When `true`, removes nested objects from the returned value so every validated leaf becomes a top-level key.
|
|
212
|
-
| `flattenKeyStyle` | `'path'` | Controls flattened key naming when `flattenOutput` is `true`. Use `'path'` for full dot-notation keys or `'leaf'` for direct leaf names. Invalid values throw a `BAD_INPUT` error.
|
|
212
|
+
| Option | Default | Behavior |
|
|
213
|
+
| -------------------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
214
|
+
| `optionalProperties` | `[]` | Additional property paths that may be present. Absent optional paths are ignored. Present optional paths must be valid. |
|
|
215
|
+
| `convertToSnakeCase` | `false` | When `true`, converts returned keys, including nested keys, to snake_case using the browser-safe `@carecard/common-util/case-converter` entrypoint. Conversion happens before flattening. |
|
|
216
|
+
| `flattenOutput` | `false` | When `true`, removes nested objects from the returned value so every validated leaf becomes a top-level key. |
|
|
217
|
+
| `flattenKeyStyle` | `'path'` | Controls flattened key naming when `flattenOutput` is `true`. Use `'path'` for full dot-notation keys or `'leaf'` for direct leaf names. Invalid values throw a `BAD_INPUT` error. |
|
|
213
218
|
|
|
214
219
|
Example with only the default options:
|
|
215
220
|
|