Skip to content

Commit

Permalink
fix: auto retry bug (#1639)
Browse files Browse the repository at this point in the history
  • Loading branch information
gitanjli525 authored Oct 24, 2024
1 parent 9ff488b commit 46f4de6
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions src/screens/Settings/MerchantAccountUtils.res
Original file line number Diff line number Diff line change
Expand Up @@ -403,14 +403,6 @@ let validateCustom = (key, errors, value, isLiveMode) => {
Dict.set(errors, key->validationFieldsMapper, "Please Enter Valid URL"->JSON.Encode.string)
}
}
| MaxAutoRetries =>
if !RegExp.test(%re("/^(?:[1-5])$/"), value) {
Dict.set(
errors,
key->validationFieldsMapper,
"Please enter integer value from 1 to 5"->JSON.Encode.string,
)
}
| _ => ()
}
}
Expand All @@ -426,16 +418,24 @@ let validateMerchantAccountForm = (

let valuesDict = values->getDictFromJsonObject
fieldsToValidate->Array.forEach(key => {
let val = valuesDict->getJsonObjectFromDict(key->validationFieldsMapper)

switch val->JSON.Classify.classify {
| String(str) =>
switch str->getNonEmptyString {
| Some(str) => key->validateCustom(errors, str, isLiveMode)
| _ => ()
switch key {
| MaxAutoRetries => {
let value = getInt(valuesDict, key->validationFieldsMapper, 0)
if !RegExp.test(%re("/^(?:[1-5])$/"), value->Int.toString) {
Dict.set(
errors,
key->validationFieldsMapper,
"Please enter integer value from 1 to 5"->JSON.Encode.string,
)
}
}
| _ => {
let value = getString(valuesDict, key->validationFieldsMapper, "")->getNonEmptyString
switch value {
| Some(str) => key->validateCustom(errors, str, isLiveMode)
| _ => ()
}
}
| Number(num) => key->validateCustom(errors, num->Float.toString, isLiveMode)
| _ => ()
}
})

Expand Down

0 comments on commit 46f4de6

Please sign in to comment.