UNPKG

glide-nodejs-sdk

Version:

Glide NodeJS SDK

77 lines (67 loc) 2.57 kB
const { object, string, number, array, mixed } = require("yup"); const createWalletSchema = object().shape({ firstName: string().required(), lastName: string().required(), email: string().label("Émail").email(), password: string().label("Password").min(6), phoneNumber: string().label("Phone Number").required(), dateOfBirth: string().label("Date of Birth").required(), currency: string().default("NGN").oneOf(["NGN"]), customerId: string(), metadata: mixed(), bvn: string().trim().length(11).label("Bvn").default("00000000000"), }); const walletTransactionSchema = object().shape({ metadata: mixed(), customerId: string().required(), amount: number().required().min(1), reference: string().min(10, "Reference can not be less than 10 characters"), }); const walletPinSchema = object().shape({ pin: string().required(), customerId: string().required(), }); const walletToWalletTransferSchema = object().shape({ amount: number().min(1).label("Amount").required(), toCustomerId: string().label("To Customer ID").required(), fromCustomerId: string().label("To Recipient ID").required(), }); const batchCreditCustomerSchema = object().shape({ transactions: array() .of( object({ customerId: string().required(), amount: number().min(0).required(), reference: string().min(10, "Reference can not be less than 10 characters"), }) ) .compact((value) => { const isValidPayoad = value.amount > 1 && !!value.customerId; return !isValidPayoad; }), batchReference: string().min(10, "Batch reference cannot be less than 10 characters"), }); const customerBatchCreditCustomersSchema = object().shape({ customerId: string().required(), batchReference: string().min(10, "Batch reference cannot be less than 10 characters"), recipients: array() .of( object({ customerId: string().required(), amount: number().min(0).required(), reference: string().min(10, "Reference can not be less than 10 characters"), }) ) .compact((value) => { const isValidPayoad = value.amount > 1 && !!value.customerId; return !isValidPayoad; }), }); module.exports = { walletPinSchema, createWalletSchema, walletTransactionSchema, batchCreditCustomerSchema, walletToWalletTransferSchema, customerBatchCreditCustomersSchema, };