ss validate boost acts

This commit is contained in:
k00b 2024-09-19 13:38:13 -05:00
parent 5f0494de30
commit d17929f2c5
1 changed files with 15 additions and 7 deletions

View File

@ -585,17 +585,25 @@ export const amountSchema = object({
amount: intValidator.required('required').positive('must be positive')
})
export const boostValidator = intValidator
.min(BOOST_MULT, `must be at least ${BOOST_MULT}`).test({
name: 'boost',
test: async boost => boost % BOOST_MULT === 0,
message: `must be divisble be ${BOOST_MULT}`
})
export const boostSchema = object({
amount: intValidator
.min(BOOST_MULT, `must be at least ${BOOST_MULT}`).test({
name: 'boost',
test: async boost => boost % BOOST_MULT === 0,
message: `must be divisble be ${BOOST_MULT}`
})
amount: boostValidator.required('required').positive('must be positive')
})
export const actSchema = object({
sats: intValidator.required('required').positive('must be positive'),
sats: intValidator.required('required').positive('must be positive')
.when(['act'], ([act], schema) => {
if (act === 'BOOST') {
return boostValidator
}
return schema
}),
act: string().required('required').oneOf(['TIP', 'DONT_LIKE_THIS', 'BOOST'])
})