# PropertyMetadata Class

Module
import { PropertyMetadata } from "@tsed/common"
Source/packages/common/src/mvc/models/PropertyMetadata.ts

# Overview

class PropertyMetadata extends Storable implements IPropertyOptions {
    /**
     * Allowed value when the entity is required.
     * @type {Array}
     */
    allowedRequiredValues: any[];
    ignoreProperty: boolean;
    onSerialize: Function;
    onDeserialize: Function;
    constructor(target: any, propertyKey: any);
    /**
     *
     * @returns {Type<any>}
     */
    get type(): Type<any>;
    /**
     *
     * @param value
     */
    set type(value: Type<any>);
    /**
     *
     * @returns {JsonSchema}
     */
    get schema(): JsonSchema;
    /**
     * Return the required state.
     * @returns {boolean}
     */
    get required(): boolean;
    /**
     * Change the state of the required data.
     * @param value
     */
    set required(value: boolean);
    /**
     *
     * @param target
     * @param propertyKey
     * @returns {PropertyMetadata}
     */
    static get(target: Type<any>, propertyKey: string | symbol): PropertyMetadata;
    /**
     *
     * @param target
     * @param options
     * @returns {Array}
     */
    static getProperties(target: Type<any>, options?: Partial<{
        withIgnoredProps: boolean;
    }>): Map<string | symbol, PropertyMetadata>;
    /**
     *
     * @param {Type<any>} target
     * @returns {Map<string | symbol, PropertyMetadata>}
     */
    static getOwnProperties(target: Type<any>): Map<string | symbol, PropertyMetadata>;
    /**
     *
     * @param target
     * @param propertyKey
     * @param property
     */
    static set(target: Type<any>, propertyKey: string | symbol, property: PropertyMetadata): void;
    /**
     * Check precondition between value, required and allowedRequiredValues to know if the entity is required.
     * @param value
     * @returns {boolean}
     */
    isRequired(value: any): boolean;

}

# Members

allowedRequiredValues: any[];

Allowed value when the entity is required.


ignoreProperty: boolean;

onSerialize: Function;

onDeserialize: Function;

get type(): Type<any>;

set type(value: Type<any>);

get schema(): JsonSchema;

get required(): boolean;

Return the required state.


set required(value: boolean);

Change the state of the required data.


static get(target: Type<any>, propertyKey: string | symbol): PropertyMetadata;

static getProperties(target: Type<any>, options?: Partial<{
     withIgnoredProps: boolean;
 }>): Map<string | symbol, PropertyMetadata>;

static getOwnProperties(target: Type<any>): Map<string | symbol, PropertyMetadata>;

static set(target: Type<any>, propertyKey: string | symbol, property: PropertyMetadata): void;

isRequired(value: any): boolean;

Check precondition between value, required and allowedRequiredValues to know if the entity is required.