import { Handler, HandlerRecipe } from './handler'; import { Model } from './models'; import { CastConfig, CastHandler } from './parser'; import { Validator, ValidatorRecipe } from './validator'; /** * Property error interface. */ export interface PropError { path: Array; errors: number[]; } /** * Model property class configuration object. */ export interface PropRef { path: string[]; prop: Prop; } /** * Model property class configuration object. */ export interface PropCast extends CastConfig { handler?: CastHandler | any; } /** * Model property class configuration object. */ export interface PropConfig { set?: (v: any) => any; get?: (v: any) => any; cast?: PropCast; defaultValue?: any | (() => any); fakeValue?: any | (() => any); emptyValue?: any | (() => any); validator?: Validator | (() => Validator); validate?: ValidatorRecipe[]; handler?: Handler | (() => Handler); handle?: HandlerRecipe[]; populatable?: string[]; serializable?: string[]; enumerable?: boolean; model?: Model; } /** * Property decorator for model. */ export declare function prop(config?: PropConfig): (target: any, key: string) => void; /** * Model property class. */ export declare class Prop { readonly $config: PropConfig; protected rawValue: any | (() => any); protected initialValue: any | (() => any); protected errorCodes: number[]; protected frozen: boolean; /** * Class constructor. * @param config Model prop configuration. */ constructor(config?: PropConfig); /** * Returns model reference. */ getModel(): Model; /** * Sets the current value. */ setValue(data: any | (() => any), strategy?: string): void; /** * Calculates the current value. */ getValue(): any; /** * Sets local error codes. */ setErrorCodes(...codes: number[]): void; /** * Gets local error codes. */ getErrorCodes(): number[]; /** * Returns raw property value. */ getRawValue(): any; /** * Returns property value on last commit. */ getInitialValue(): any; /** * Returns `true` if the property type represents a Model. */ isModel(): boolean; /** * Returns `true` if the property is an array. */ isArray(): boolean; /** * Returns `true` if the property value can be set based on the strategy. * @param strategy Populatable strategy. */ isPopulatable(strategy?: string): boolean; /** * Returns `true` if the property value can be read based on the strategy. * @param strategy Serialization strategy. */ isSerializable(strategy?: string): boolean; /** * Returns true if the property value is an empty value. */ isEmpty(): boolean; /** * Returns `true` if the value has been changed. */ isChanged(): boolean; /** * Returns `true` when `data` deeply equals the current value. */ isEqual(data: any): boolean; /** * Returns `true` when the value and possible nested models have no errors. */ isValid(): boolean; /** * Returns JSON serialized property value. */ serialize(strategy?: string): any; /** * Sets property value to the default value. */ reset(): this; /** * Deeply sets property value to the fake value. */ fake(): this; /** * Sets property value to empty value. */ empty(): this; /** * Saves the local property value to initial value. */ commit(): this; /** * Sets local property value to the initial value. */ rollback(): this; /** * Makes this property not settable. */ freeze(): this; /** * Validates the property and sets errors codes. */ validate(): Promise; /** * Handles property error and sets error codes. */ handle(error: any): Promise; /** * Clears errors. */ invalidate(): this; /** * Converts the provided value to the property type. */ protected cast(value: any, strategy?: string): any; } //# sourceMappingURL=props.d.ts.map