Call all element property validators before command

asked 2015-02-10 11:40:46 +0800

JustinFrost gravatar image JustinFrost
145 1 6

updated 2015-02-11 01:07:44 +0800

I have setup bind validators on all of my elements as follows

@bind(vm.user.email) @validator(vm.emailValidator)

This is validating data as I leave the field as expected. In addition to this validation, I would like to call the validation on each element before my save command. Ie onClick of my save button.

So I want both property validation onChange of the field and also property validation for each field when the save button is clicked..

How do I do this ?


delete flag offensive retag edit

1 Answer

Sort by ยป oldest newest most voted

answered 2015-02-10 12:13:16 +0800

chillworld gravatar image chillworld flag of Belgium
5337 4 9

updated 2015-02-10 12:13:41 +0800

hey Julien,

Did you try this :

@load(vm.user.email) @save(vm.user.email, before='save') @validator(vm.emailValidator)

I know from experience that this work when you fill in the constraint like :

constraint="not empty"

If your emailvalidator only contains a regex, you could put that also in the constraint attribute.

greetz chill.

link publish delete flag offensive edit


Thanks chilliworld. I am after a way to do both validation onChange and then call that same validation for each field onSave. From reading the doco it seems the above will only invoke the emailValidator before the save command and will not do any onChange validation.

JustinFrost ( 2015-02-10 23:34:36 +0800 )edit

yes indeed, must have read bad with tyhe onChange. I think it's better to do it with the onBlur event then the onchange event.(pretty anoying when constraints are coming up when you typ)

chillworld ( 2015-02-11 03:34:20 +0800 )edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

1 follower



Asked: 2015-02-10 11:40:46 +0800

Seen: 17 times

Last updated: Feb 11 '15

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More