Libraries
    Preparing search index...

    Type Alias PropertyDescriptorInner<TSchema, TPropertySchema, TParentPropertyDescriptor, TPropertyKey>

    type PropertyDescriptorInner<
        TSchema extends ObjectSchemaBuilder<any, any, any, any, any>,
        TPropertySchema,
        TParentPropertyDescriptor,
        TPropertyKey extends string = string,
    > = {
        getSchema: () => TPropertySchema;
        getValue: (
            obj: InferType<TSchema>,
        ) => { success: boolean; value?: InferType<TPropertySchema> };
        parent: PropertyDescriptorInnerFromPropertyDescriptor<
            TParentPropertyDescriptor,
        >;
        propertyName: TPropertyKey
        | undefined;
        setValue: (
            obj: InferType<TSchema>,
            value: InferType<TPropertySchema>,
            options?: PropertySetterOptions,
        ) => boolean;
        toJsonPointer: () => string;
    }

    Type Parameters

    • TSchema extends ObjectSchemaBuilder<any, any, any, any, any>
    • TPropertySchema
    • TParentPropertyDescriptor
    • TPropertyKey extends string = string
    Index

    Properties

    getSchema: () => TPropertySchema

    Gets the schema for the property described by the property descriptor.

    Type Declaration

    getValue: (
        obj: InferType<TSchema>,
    ) => { success: boolean; value?: InferType<TPropertySchema> }

    Gets the value of the property from the object.

    Type Declaration

      • (
            obj: InferType<TSchema>,
        ): { success: boolean; value?: InferType<TPropertySchema> }
      • Parameters

        Returns { success: boolean; value?: InferType<TPropertySchema> }

        an object containing a value and success properties. value is the value of the property if it was found in the object, success is a boolean value indicating if the property was found in the object.

    parent: PropertyDescriptorInnerFromPropertyDescriptor<TParentPropertyDescriptor>
    propertyName: TPropertyKey | undefined

    The name of this property within its parent object, or undefined for the root descriptor.

    When the property was created from a PropertyDescriptorTree leaf the type narrows to the literal key string (e.g. 'id'), enabling accessor-function-based column inference in query builders.

    The literal property name, or string for root/unknown descriptors.

    setValue: (
        obj: InferType<TSchema>,
        value: InferType<TPropertySchema>,
        options?: PropertySetterOptions,
    ) => boolean

    Sets a new value to the property. If the process was successful, the method returns true, otherwise false. It can return false if the property could not be set to the object which can happen if the setValue method is called with an object which does not comply with the schema. for example, if you have a schema and property descriptopr like this:

    const schema = object({
    name: string(),
    address: object({
    city: string(),
    country: string()
    }),
    id: number()
    });

    const addressCityDescriptor = object.getPropertiesFor(schema).address.city;

    And then you try to set a new value to the address.city property on the object which does not have address property:

    const obj = {
    name: 'Leo'
    };

    const success = addressCityDescriptor.setValue(obj, 'Venyov');
    // success === false

    Type Declaration

    toJsonPointer: () => string

    Returns a JSON Pointer (RFC 6901) string representing this property's path from the root descriptor.

    Property names are escaped per RFC 6901 (~~0, /~1). The root descriptor returns an empty string ('').