Only validate tipRandom if enabled (#1284)
* Only validate tipRandom if enabled * Use consistent naming scheme for zap settings --------- Co-authored-by: Keyan <34140557+huumn@users.noreply.github.com>
This commit is contained in:
parent
5d0e071939
commit
288fa37197
|
@ -542,17 +542,20 @@ export const actSchema = object({
|
|||
|
||||
export const settingsSchema = object().shape({
|
||||
tipDefault: intValidator.required('required').positive('must be positive'),
|
||||
tipRandom: boolean(),
|
||||
tipRandomMin: intValidator.nullable().positive('must be positive')
|
||||
.when(['tipRandomMax'], ([max], schema) => {
|
||||
.when(['tipRandom', 'tipRandomMax'], ([enabled, max], schema) => {
|
||||
let res = schema
|
||||
if (!enabled) return res
|
||||
if (max) {
|
||||
res = schema.required('minimum and maximum must either both be omitted or specified').nonNullable()
|
||||
}
|
||||
return res.lessThan(max, 'must be less than maximum')
|
||||
}),
|
||||
tipRandomMax: intValidator.nullable().positive('must be positive')
|
||||
.when(['tipRandomMin'], ([min], schema) => {
|
||||
.when(['tipRandom', 'tipRandomMin'], ([enabled, min], schema) => {
|
||||
let res = schema
|
||||
if (!enabled) return res
|
||||
if (min) {
|
||||
res = schema.required('minimum and maximum must either both be omitted or specified').nonNullable()
|
||||
}
|
||||
|
|
|
@ -1040,7 +1040,7 @@ const TipRandomField = () => {
|
|||
groupClassName='mb-0'
|
||||
label={
|
||||
<div className='d-flex align-items-center'>
|
||||
random zap values
|
||||
random zaps
|
||||
<Info>
|
||||
<ul className='fw-bold'>
|
||||
<li>Set a minimum and maximum zap amount</li>
|
||||
|
|
Loading…
Reference in New Issue