Skip to content

Error: [serializr] this value is not primitive: [object Object], can't figure out what's next #163

@redhatpanda

Description

@redhatpanda

So I have a model which is as such:

export default class VendorProduce {
    @ serializable(identifier())
    public id = uuidv4()

    @serializable
    public vendorId: string

    @serializable
    public produceName: string

    @serializable
    public stockStatus: string

    @serializable
    public minPrice: string

    @serializable
    public maxPrice: string

    @serializable
    public stockCount: string 

    @serializable
    public produceVariants: object

    constructor(
        vendorId: string,
        produceName: string,
        stockStatus: string,
        minPrice: string,
        maxPrice: string,
        stockCount: string,
        produceVariants: {
            variantName: {
                days: string,
                image: string
            }
        }
    ) {
        this.vendorId = vendorId
        this.produceName = produceName
        this.stockStatus = stockStatus
        this.minPrice = minPrice
        this.maxPrice = maxPrice
        this.stockCount = stockCount
        this.produceVariants = produceVariants
        makeAutoObservable(this)
    }

    static validationSchema = yup.object().shape({
        vendorId: yup.string().required('This field is required'),
        produceName: yup.string().required('This field is required'),
        stockStatus: yup.string().required('This field is required'),
        minPrice: yup.string().required('This field is required'),
        maxPrice: yup.string().required('This field is required'),
        stockCount: yup.string().required('This field is required'),
        produceVariants: yup.object().required('This field is required'),
    })
} 

Upon this model getting called during some API Calls I get the following error:
image

I am new to using Serializr and not being able to understand how to fix this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions