@sprucelabs/schema
Version:
Static and dynamic binding plus runtime validation and transformation to ensure your app is sound. 🤓
4 lines (3 loc) • 1.65 kB
TypeScript
import { Schema, SchemaPartialValues, SchemaGetValuesOptions, SchemaFieldNames, SchemaPublicFieldNames, IsDynamicSchema, DynamicSchemaAllValues, SchemaValues } from '../schemas.static.types';
import { ValuesWithPaths } from '../types/utilities.types';
export default function normalizeSchemaValues<S extends Schema, F extends SchemaFieldNames<S> = SchemaFieldNames<S>, PF extends SchemaPublicFieldNames<S> = SchemaPublicFieldNames<S>, CreateEntityInstances extends boolean = false, IncludePrivateFields extends boolean = true, IsDynamic extends boolean = IsDynamicSchema<S>, ShouldIncludeNullAndUndefinedFields extends boolean = true, ExcludeFields extends SchemaFieldNames<S> | undefined = undefined, PublicExcludeFields extends SchemaPublicFieldNames<S> | undefined = undefined>(schema: S, values: ValuesWithPaths<SchemaPartialValues<S>> | SchemaValues<S>, options?: SchemaGetValuesOptions<S, F, PF, CreateEntityInstances, IncludePrivateFields, ShouldIncludeNullAndUndefinedFields, ExcludeFields, PublicExcludeFields>): IsDynamic extends true ? DynamicSchemaAllValues<S, CreateEntityInstances> : IncludePrivateFields extends true ? ExcludeFields extends SchemaFieldNames<S> ? Omit<Pick<SchemaValues<S, CreateEntityInstances, true, ShouldIncludeNullAndUndefinedFields>, F>, ExcludeFields> : Pick<SchemaValues<S, CreateEntityInstances, true, ShouldIncludeNullAndUndefinedFields>, F> : PublicExcludeFields extends SchemaFieldNames<S> ? Omit<Pick<SchemaValues<S, CreateEntityInstances, true, ShouldIncludeNullAndUndefinedFields>, PF>, PublicExcludeFields> : Pick<SchemaValues<S, CreateEntityInstances, true, ShouldIncludeNullAndUndefinedFields>, PF>;