@travetto/schema
Advanced tools
Comparing version 0.0.29 to 0.0.30
@@ -28,3 +28,3 @@ { | ||
}, | ||
"version": "0.0.29" | ||
"version": "0.0.30" | ||
} |
@@ -1,20 +0,9 @@ | ||
import { Field } from './field'; | ||
import { Class } from '@travetto/registry'; | ||
import { SchemaRegistry, ValidatorFn } from '../service'; | ||
import { Class } from '@travetto/registry'; | ||
import { BindUtil } from '../util'; | ||
export type DeepPartial<T> = { | ||
[P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P] | ||
}; | ||
export interface ClassWithSchema<T> { | ||
new(...args: any[]): T; | ||
from<U>(this: Class<U>, data: DeepPartial<U & { [key: string]: any }>, view?: string): U; | ||
} | ||
export function Schema(auto: boolean = true): ClassDecorator { | ||
return <T>(target: Class<T>): ClassWithSchema<T> => { | ||
const res: ClassWithSchema<T> = target as any; | ||
return <T>(target: Class<T>): Class<T> => { | ||
const res: Class<T> = target as any; | ||
SchemaRegistry.getOrCreatePending(target); | ||
if (!res.from) { | ||
@@ -26,3 +15,2 @@ res.from = function (data: any, view: any) { | ||
} | ||
return res; | ||
@@ -29,0 +17,0 @@ }; |
@@ -13,2 +13,2 @@ type DeepPartial<T> = { | ||
): U; | ||
} | ||
} |
import { | ||
Field, Url, View, Required, Alias, | ||
BindUtil, Schema, SchemaRegistry, ClassWithSchema, Float, Integer | ||
BindUtil, Schema, SchemaRegistry, Float, Integer | ||
} from '../src'; | ||
@@ -5,0 +5,0 @@ import { Address } from './address'; |
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
46937
1366