Comparing version 1.0.0-alpha.7 to 1.0.0-alpha.9
@@ -5,2 +5,6 @@ export interface ISchemaValueBase { | ||
} | ||
export interface ISchemaValueAny extends ISchemaValueBase { | ||
type: 'any'; | ||
default?: () => any; | ||
} | ||
export interface ISchemaValueArray extends ISchemaValueBase { | ||
@@ -54,3 +58,3 @@ type: 'array'; | ||
} | ||
export declare type SchemaValue = ISchemaValueArray | ISchemaValueBoolean | ISchemaValueDate | ISchemaValueModel | ISchemaValueNumber | ISchemaValueObject | ISchemaValueReference | ISchemaValueString; | ||
export declare type SchemaValue = ISchemaValueAny | ISchemaValueArray | ISchemaValueBoolean | ISchemaValueDate | ISchemaValueModel | ISchemaValueNumber | ISchemaValueObject | ISchemaValueReference | ISchemaValueString; | ||
export interface ISchemaMap { | ||
@@ -57,0 +61,0 @@ [field: string]: SchemaValue; |
@@ -65,2 +65,3 @@ "use strict"; | ||
return data; | ||
case 'any': | ||
case 'boolean': | ||
@@ -143,2 +144,3 @@ case 'date': | ||
return value; | ||
case 'any': | ||
case 'boolean': | ||
@@ -145,0 +147,0 @@ case 'date': |
@@ -14,2 +14,15 @@ import { ArrayCollection } from './array-collection'; | ||
describe('type any', () => { | ||
const schemaAny: SchemaValue = {type: 'any', default: () => ({foo: 42})}; | ||
it('should return the input', () => { | ||
const value = {foo: 'bar'}; | ||
expect(sanitize(schemaAny, value)).to.equal(value); | ||
}); | ||
it('should return default value if undefined', () => { | ||
expect(sanitize(schemaAny, undefined, {defaults: true})).to.eql({foo: 42}); | ||
}); | ||
}); | ||
describe('type array', () => { | ||
@@ -301,2 +314,10 @@ const schemaStringArray: SchemaValue = {type: 'array', definition: {type: 'string'}}; | ||
describe('type any', () => { | ||
it('should return the value', () => { | ||
const schema: SchemaValue = {type: 'any'}; | ||
const value = {foo: 'bar'}; | ||
expect(toObjectValue(schema, value)).to.eql(value); | ||
}); | ||
}); | ||
describe('type array', () => { | ||
@@ -349,4 +370,5 @@ it('should clone an array', () => { | ||
describe('types boolean, date, number, string', () => { | ||
describe('types any, boolean, date, number, string', () => { | ||
it('should just return the primitive', () => { | ||
expect(toObjectValue({type: 'any'}, {foo: 'bar'})).to.eql({foo: 'bar'}); | ||
expect(toObjectValue({type: 'boolean'}, false)).to.equal(false); | ||
@@ -353,0 +375,0 @@ const date = new Date(); |
@@ -10,2 +10,7 @@ import { difference, forEach, isArray, isBoolean, isDate, isFunction, isNumber, isString } from 'lodash'; | ||
export interface ISchemaValueAny extends ISchemaValueBase { | ||
type: 'any'; | ||
default?: () => any; | ||
} | ||
export interface ISchemaValueArray extends ISchemaValueBase { | ||
@@ -68,5 +73,5 @@ type: 'array'; | ||
export type SchemaValue = ISchemaValueArray | ISchemaValueBoolean | ISchemaValueDate | | ||
ISchemaValueModel | ISchemaValueNumber | ISchemaValueObject | ISchemaValueReference | | ||
ISchemaValueString; | ||
export type SchemaValue = ISchemaValueAny | ISchemaValueArray | ISchemaValueBoolean | | ||
ISchemaValueDate | ISchemaValueModel | ISchemaValueNumber | ISchemaValueObject | | ||
ISchemaValueReference | ISchemaValueString; | ||
@@ -156,2 +161,3 @@ export interface ISchemaMap { | ||
case 'any': | ||
case 'boolean': | ||
@@ -257,2 +263,3 @@ case 'date': | ||
case 'any': | ||
case 'boolean': | ||
@@ -259,0 +266,0 @@ case 'date': |
{ | ||
"name": "octonom", | ||
"version": "1.0.0-alpha.7", | ||
"version": "1.0.0-alpha.9", | ||
"description": "Object Document Mapper for any database", | ||
@@ -5,0 +5,0 @@ "main": "build/lib/main.js", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
125932
2538