mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-20 13:32:00 +00:00
refactor(FE-212): update qty validation in PurchaseRequestForm schema to enforce numeric input
This commit is contained in:
@@ -71,19 +71,10 @@ const PurchaseItemObjectSchema: Yup.ObjectSchema<PurchaseItemSchema> =
|
||||
.required('Produk wajib dipilih!')
|
||||
.min(1, 'Produk wajib dipilih!')
|
||||
.typeError('Produk wajib dipilih!'),
|
||||
qty: Yup.mixed<string | number>()
|
||||
qty: Yup.number()
|
||||
.required('Kuantitas wajib diisi!')
|
||||
.test(
|
||||
'is-valid-qty',
|
||||
'Kuantitas harus berupa angka lebih dari 0!',
|
||||
function (value) {
|
||||
if (value === '' || value === null || value === undefined)
|
||||
return false;
|
||||
const numValue =
|
||||
typeof value === 'string' ? parseFloat(value) : value;
|
||||
return !isNaN(numValue) && numValue > 0;
|
||||
}
|
||||
),
|
||||
.min(1, 'Kuantitas tidak boleh kurang dari 1!')
|
||||
.typeError('Kuantitas wajib diisi!'),
|
||||
});
|
||||
|
||||
export const PurchaseRequestFormSchema: Yup.ObjectSchema<PurchaseRequestFormSchemaType> =
|
||||
|
||||
Reference in New Issue
Block a user