Skip to content

Commit

Permalink
fix(schema): Don't override spec values with undefined jquense#1160
Browse files Browse the repository at this point in the history
  • Loading branch information
cemalettin-work committed Dec 12, 2020
1 parent e785e1a commit 8f620ad
Showing 1 changed file with 23 additions and 21 deletions.
44 changes: 23 additions & 21 deletions src/schema.ts
Original file line number Diff line number Diff line change
@@ -1,33 +1,28 @@
// @ts-ignore
import cloneDeep from 'nanoclone';

import { mixed as locale } from './locale';
import Condition, { ConditionOptions, ResolveOptions } from './Condition';
import runTests from './util/runTests';
import { mixed as locale } from './locale';
import { default as Ref, default as Reference } from './Reference';
import {
AnyObject, Callback,


ExtraParams, InternalOptions,
Maybe, Message, TransformFunction, ValidateOptions
} from './types';
import createValidation, {
TestFunction,
Test,
TestConfig,
TestConfig, TestFunction
} from './util/createValidation';
import printValue from './util/printValue';
import Ref from './Reference';
import { getIn } from './util/reach';
import ReferenceSet from './util/ReferenceSet';
import runTests from './util/runTests';
import toArray from './util/toArray';
import {
ValidateOptions,
TransformFunction,
Message,
Callback,
InternalOptions,
Maybe,
ExtraParams,
AnyObject,
} from './types';

import ValidationError from './ValidationError';
import type { Asserts, Thunk } from './util/types';
import ReferenceSet from './util/ReferenceSet';
import Reference from './Reference';
import ValidationError from './ValidationError';



// const UNSET = 'unset' as const;

Expand Down Expand Up @@ -229,7 +224,14 @@ export default abstract class BaseSchema<
let base = this;
let combined = schema.clone();

const mergedSpec = { ...base.spec, ...combined.spec };
const baseSpec = { ...base.spec };
// only override with spec values which are not undefine
const mergedSpec = Object.keys(combined.spec).reduce((accum, key) => {
if (combined.spec[key] !== undefined){
accum[key] = combined.spec[key]
}
return accum;
}, baseSpec)

// if (combined.spec.nullable === UNSET)
// mergedSpec.nullable = base.spec.nullable;
Expand Down

0 comments on commit 8f620ad

Please sign in to comment.