Skip to content

Commit 98a7652

Browse files
authored
feat(formvalidation): support prompt functions for settings value
Prompt functions are only supported when specified via custom rule declarations. In case one wants to supply a prompt function as a setting instead, this breaks the code and results into "prompt.search is not a function" when validatin the form
1 parent a8681bf commit 98a7652

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/definitions/behaviors/form.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -558,9 +558,10 @@
558558
ancillary = module.get.ancillaryValue(rule),
559559
$field = module.get.field(field.identifier),
560560
value = $field.val(),
561-
prompt = isFunction(rule.prompt)
562-
? rule.prompt.call($field[0], value)
563-
: rule.prompt || settings.prompt[ruleName] || settings.text.unspecifiedRule,
561+
promptCheck = rule.prompt || settings.prompt[ruleName] || settings.text.unspecifiedRule,
562+
prompt = String(isFunction(promptCheck)
563+
? promptCheck.call($field[0], value)
564+
: promptCheck),
564565
requiresValue = prompt.search('{value}') !== -1,
565566
requiresName = prompt.search('{name}') !== -1,
566567
parts,

0 commit comments

Comments
 (0)