Open redhatpanda opened 2 years ago
It is likely about the produceVariants field which is not a primitive but object
On Sun, 24 Jul 2022, 03:12 Swapnanil Ray, @.***> wrote:
So I have a model which is as such: `export default class VendorProduce { @serializable https://github.com/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: image] https://user-images.githubusercontent.com/67406959/180629293-da4a5f9e-7ac4-4d82-8f00-4e4ae1f401b2.png
I am new to using Serializr and not being able to understand how to fix this.
— Reply to this email directly, view it on GitHub https://github.com/mobxjs/serializr/issues/163, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAN4NBAKUNSNZYHPRVS5WUDVVSRAVANCNFSM54O4H57A . You are receiving this because you are subscribed to this thread.Message ID: @.***>
@mweststrate Hey, thanks for pointing that out! But i just wanted to know, can we not use non primitive types like object here? If not, what can be the way out?
An object is not a primitive value. See https://github.com/mobxjs/serializr#propschema for the available options.
On Sun, 24 Jul 2022, 09:23 Swapnanil Ray, @.***> wrote:
Can we not use object here?
— Reply to this email directly, view it on GitHub https://github.com/mobxjs/serializr/issues/163#issuecomment-1193271101, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAN4NBDQKS2A7YZHCHLGCJ3VVT4RJANCNFSM54O4H57A . You are receiving this because you commented.Message ID: @.***>
I think this issue can be closed, because the underlying cause and and a documentation link have been provided
So I have a model which is as such:
Upon this model getting called during some API Calls I get the following error:
I am new to using Serializr and not being able to understand how to fix this.