Skip to content

Commit

Permalink
Merge pull request nitrogen#10 from anha0825/master
Browse files Browse the repository at this point in the history
is_integer validator didn't implement render_action/1
  • Loading branch information
choptastic committed Aug 3, 2011
2 parents 3da5965 + 6bd61a6 commit d855349
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/validators/validator_is_integer.erl
Expand Up @@ -6,10 +6,14 @@
-include_lib ("wf.hrl").
-compile(export_all).

render_validator(TriggerPath, TargetPath, Record) ->
render_action(Record) ->
TriggerPath = Record#is_integer.trigger,
TargetPath = Record#is_integer.target,
Text = wf:js_escape(Record#is_integer.text),
validator_custom:render_validator(TriggerPath, TargetPath, #custom { function=fun validate/2, text = Text, tag=Record }),
wf:f("v.add(Validate.Numericality, { notAnIntegerMessage: \"~s\", onlyInteger: true });", [Text]).
CustomValidatorAction = #custom { trigger=TriggerPath, target=TargetPath, function=fun validate/2, text = Text, tag=Record },
Script = wf:f("v.add(Validate.Numericality, { notAnIntegerMessage: \"~s\", onlyInteger: true });", [Text]),
[CustomValidatorAction, Script].


validate(_, Value) ->
try is_integer(list_to_integer(Value)) == true
Expand Down

0 comments on commit d855349

Please sign in to comment.