import { IOttomanType } from '../schema'; import { CoreType } from '../schema/types'; /** * Cast Strategies * 'keep' | 'drop' | 'throw' | 'defaultOrDrop' | 'defaultOrKeep' * * @desc * When trying to cast a value to a given type if it fail Cast Strategy will behave this ways for: * + 'keep' -> The original value will be returned * + 'drop' -> Return undefined and the object field will be removed. * + 'throw' -> Throw exception 'Value couldn't be casted to given type' * + 'defaultOrDrop' -> Try to return default value if exists, if no default value was provided for the current field then it will be removed * + 'defaultOrDrop' -> Try to return default value if exists, if no default value was provided for the current field then it will keep original value. */ export declare enum CAST_STRATEGY { KEEP = "keep", DROP = "drop", THROW = "throw", DEFAULT_OR_DROP = "defaultOrDrop", DEFAULT_OR_KEEP = "defaultOrKeep" } export declare const ensureArrayItemsType: (array: any, field: any, strategy: any) => any; export declare const ensureTypes: (item: any, field: IOttomanType, strategy?: CAST_STRATEGY | undefined) => unknown; export interface CastOptions { strategy?: CAST_STRATEGY; strict?: boolean; skip?: string[]; } /** * @desc * Used when trying to apply a value to a given immutable property: * + **false** -> Allow apply the new value * + **true** -> Don't allow apply the new value * + **'throw'** -> Throw exception "ImmutableError: Field 'field_name' is immutable and current cast strategy is set to 'throw'" */ export declare type ApplyStrategy = boolean | CAST_STRATEGY.THROW; /** * @desc * Used by the mutations functions to apply the defined strategy */ export declare type MutationFunctionOptions = { strict?: ApplyStrategy; }; export declare const cast: (data: any, schema: any, options?: CastOptions) => any; export declare const checkCastStrategy: (value: any, strategy: any, type: CoreType) => any;