8

Is is possible to see if just one property is valid in the knockout-validation plugin?

I could not see any reference to it in the documentation, only the ability to see if the whole model is valid.

For example I wish a computed observable to have a different value depending upon if another observable is valid.

delixfe
  • 2,471
  • 1
  • 21
  • 35
Alex KeySmith
  • 16,657
  • 11
  • 74
  • 152

1 Answers1

14

I was being led down the wrong direction, as I was using async validators and over complicated my problem, I think it is as simple as:

propertyName.isValid();

e.g.

self.email.isValid();

Alex KeySmith
  • 16,657
  • 11
  • 74
  • 152
  • Hello, @AlexKey. Sorry about this "bump", but I would to know why I am receiving this message from console: `Uncaught TypeError: Cannot call method 'isValid' of undefined `. Actually, I know why, but I do not know how to resolve. By chance, it happened to you? – Guilherme Oderdenge Jun 27 '13 at 14:01
  • Hi @chiefGui pop your comment into a question (so the information doesn't get lost in comments) and pop a link to it here and I'll take a look for you. – Alex KeySmith Jun 27 '13 at 14:29
  • 4
    @GuilhermeOderdenge FYI, this maybe because you're evaluating the value of the observable and not the observable itself, for example you might be doing `myObservable().isValid()` instead of `myObservable.isValid()`. Just figured that out myself and wanted to share. – SeanKilleen Aug 26 '14 at 14:01