@sprucelabs/schema 30.0.189 → 30.0.190

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.
@@ -259,17 +259,6 @@ class SchemaField extends AbstractField {
259
259
  return new Class(schema, value);
260
260
  }
261
261
  toValueType(value, options) {
262
- const errors = this.validate(value, options);
263
- if (errors.length > 0) {
264
- throw new SpruceError({
265
- code: 'TRANSFORMATION_ERROR',
266
- fieldType: 'schema',
267
- incomingTypeof: typeof value,
268
- incomingValue: value,
269
- errors,
270
- name: this.name,
271
- });
272
- }
273
262
  const { createEntityInstances, schemasById: schemasById = {} } = options || {};
274
263
  // try and pull the schema definition from the options and by id
275
264
  const destinationSchemas = SchemaField.mapFieldDefinitionToSchemas(this.definition, {
@@ -120,7 +120,7 @@ export interface SchemaNormalizeOptions<S extends Schema, CreateEntityInstances
120
120
  }
121
121
  export interface DynamicSchemaNormalizeOptions<CreateEntityInstances extends boolean> extends SchemaNormalizeFieldValueOptions<CreateEntityInstances> {
122
122
  }
123
- export type SchemaGetValuesOptions<T extends Schema, F extends SchemaFieldNames<T>, PF extends SchemaPublicFieldNames<T>, CreateEntityInstances extends boolean, IncludePrivateFields extends boolean, ShouldIncludeNullAndUndefinedFields extends boolean = true> = SchemaNormalizeOptions<T, CreateEntityInstances, ShouldIncludeNullAndUndefinedFields> & (IncludePrivateFields extends false ? {
123
+ export type SchemaGetValuesOptions<T extends Schema, F extends SchemaFieldNames<T> = SchemaFieldNames<T>, PF extends SchemaPublicFieldNames<T> = SchemaPublicFieldNames<T>, CreateEntityInstances extends boolean = false, IncludePrivateFields extends boolean = true, ShouldIncludeNullAndUndefinedFields extends boolean = true> = SchemaNormalizeOptions<T, CreateEntityInstances, ShouldIncludeNullAndUndefinedFields> & (IncludePrivateFields extends false ? {
124
124
  shouldIncludePrivateFields: IncludePrivateFields;
125
125
  fields?: PF[];
126
126
  } : {
@@ -1,6 +1,6 @@
1
1
  import SpruceError from '../errors/SpruceError.js';
2
2
  export default function normalizeFieldValue(schemaId, schemaName, schemasById, field, value, options) {
3
- var _a;
3
+ var _a, _b;
4
4
  let localValue = normalizeValueToArray(value);
5
5
  if (!Array.isArray(localValue)) {
6
6
  throw new SpruceError({
@@ -9,10 +9,11 @@ export default function normalizeFieldValue(schemaId, schemaName, schemasById, f
9
9
  friendlyMessages: [`I was expecting an array for ${field.name}.`],
10
10
  });
11
11
  }
12
- const { shouldValidate: validate = true, shouldCreateEntityInstances: createEntityInstances = true, ...extraOptions } = options !== null && options !== void 0 ? options : {};
12
+ const { shouldCreateEntityInstances: createEntityInstances = true, ...extraOptions } = options !== null && options !== void 0 ? options : {};
13
+ const validate = (_a = extraOptions.shouldValidate) !== null && _a !== void 0 ? _a : true;
13
14
  const baseOptions = {
14
15
  schemasById,
15
- ...((_a = field.definition.options) !== null && _a !== void 0 ? _a : {}),
16
+ ...((_b = field.definition.options) !== null && _b !== void 0 ? _b : {}),
16
17
  ...extraOptions,
17
18
  };
18
19
  if (value === null || typeof value === 'undefined') {
@@ -264,17 +264,6 @@ class SchemaField extends AbstractField_1.default {
264
264
  return new Class(schema, value);
265
265
  }
266
266
  toValueType(value, options) {
267
- const errors = this.validate(value, options);
268
- if (errors.length > 0) {
269
- throw new SpruceError_1.default({
270
- code: 'TRANSFORMATION_ERROR',
271
- fieldType: 'schema',
272
- incomingTypeof: typeof value,
273
- incomingValue: value,
274
- errors,
275
- name: this.name,
276
- });
277
- }
278
267
  const { createEntityInstances, schemasById: schemasById = {} } = options || {};
279
268
  // try and pull the schema definition from the options and by id
280
269
  const destinationSchemas = SchemaField.mapFieldDefinitionToSchemas(this.definition, {
@@ -120,7 +120,7 @@ export interface SchemaNormalizeOptions<S extends Schema, CreateEntityInstances
120
120
  }
121
121
  export interface DynamicSchemaNormalizeOptions<CreateEntityInstances extends boolean> extends SchemaNormalizeFieldValueOptions<CreateEntityInstances> {
122
122
  }
123
- export type SchemaGetValuesOptions<T extends Schema, F extends SchemaFieldNames<T>, PF extends SchemaPublicFieldNames<T>, CreateEntityInstances extends boolean, IncludePrivateFields extends boolean, ShouldIncludeNullAndUndefinedFields extends boolean = true> = SchemaNormalizeOptions<T, CreateEntityInstances, ShouldIncludeNullAndUndefinedFields> & (IncludePrivateFields extends false ? {
123
+ export type SchemaGetValuesOptions<T extends Schema, F extends SchemaFieldNames<T> = SchemaFieldNames<T>, PF extends SchemaPublicFieldNames<T> = SchemaPublicFieldNames<T>, CreateEntityInstances extends boolean = false, IncludePrivateFields extends boolean = true, ShouldIncludeNullAndUndefinedFields extends boolean = true> = SchemaNormalizeOptions<T, CreateEntityInstances, ShouldIncludeNullAndUndefinedFields> & (IncludePrivateFields extends false ? {
124
124
  shouldIncludePrivateFields: IncludePrivateFields;
125
125
  fields?: PF[];
126
126
  } : {
@@ -7,7 +7,7 @@ exports.default = normalizeFieldValue;
7
7
  exports.normalizeValueToArray = normalizeValueToArray;
8
8
  const SpruceError_1 = __importDefault(require("../errors/SpruceError"));
9
9
  function normalizeFieldValue(schemaId, schemaName, schemasById, field, value, options) {
10
- var _a;
10
+ var _a, _b;
11
11
  let localValue = normalizeValueToArray(value);
12
12
  if (!Array.isArray(localValue)) {
13
13
  throw new SpruceError_1.default({
@@ -16,10 +16,11 @@ function normalizeFieldValue(schemaId, schemaName, schemasById, field, value, op
16
16
  friendlyMessages: [`I was expecting an array for ${field.name}.`],
17
17
  });
18
18
  }
19
- const { shouldValidate: validate = true, shouldCreateEntityInstances: createEntityInstances = true, ...extraOptions } = options !== null && options !== void 0 ? options : {};
19
+ const { shouldCreateEntityInstances: createEntityInstances = true, ...extraOptions } = options !== null && options !== void 0 ? options : {};
20
+ const validate = (_a = extraOptions.shouldValidate) !== null && _a !== void 0 ? _a : true;
20
21
  const baseOptions = {
21
22
  schemasById,
22
- ...((_a = field.definition.options) !== null && _a !== void 0 ? _a : {}),
23
+ ...((_b = field.definition.options) !== null && _b !== void 0 ? _b : {}),
23
24
  ...extraOptions,
24
25
  };
25
26
  if (value === null || typeof value === 'undefined') {
package/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  "!build/__tests__",
9
9
  "esm"
10
10
  ],
11
- "version": "30.0.189",
11
+ "version": "30.0.190",
12
12
  "main": "./build/index.js",
13
13
  "types": "./build/index.d.ts",
14
14
  "module": "./build/esm/index.js",