Skip to content

Commit

Permalink
fix: handling if max retry calue is null, validate form should detect…
Browse files Browse the repository at this point in the history
… that
  • Loading branch information
gitanjli525 committed Oct 22, 2024
1 parent d0070ac commit 8e03c3f
Showing 1 changed file with 17 additions and 16 deletions.
33 changes: 17 additions & 16 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,15 +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 8e03c3f

Please sign in to comment.