HotDrink / hotdrink

JavaScript MVVM library with support for multi-way dependencies and generic, rich UI behaviors.
http://hotdrink.github.io/hotdrink/
58 stars 9 forks source link

Validation #41

Closed gfoust closed 11 years ago

gfoust commented 11 years ago

Validation implementation with edits discussed in group meeting

thejohnfreeman commented 11 years ago

I think the design of this feature is complex enough to write a wiki page like I did for evaluation. Points to cover:

gfoust commented 11 years ago

Sure, I'll be glad to do that when I get back. Similarly, I can do the change requests you made, but probably not till I get back. Could we go ahead and merge what we have now, however, so that it won't diverge further over the next two weeks?

Gabe

On Jul 13, 2012, at 3:00 PM, John Freeman wrote:

I think the design of this feature is complex enough to write a wiki page like I did for evaluation. Points to cover:

  • new properties added to Variable
  • the scratch proxy
  • the Translation
  • the factory process
  • hd.util
  • hd.validators
  • hd.validator
  • scratch.validate

Reply to this email directly or view it on GitHub: https://github.com/HotDrink/hotdrink/pull/41#issuecomment-6973743

thejohnfreeman commented 11 years ago

Any divergence would just have to be addressed in the mainline, which is less attractive to me. I'll hold on merging until it's ready, but I'll try to stem divergence too.

thejohnfreeman commented 11 years ago
  1. Not sure if this was said earlier, but please make pull requests against develop and not master.
  2. Is there a reason the members of ValidatorFactory are prefixed with an underscore?

I'm working on some small touchups to the patch, but there's not much. You can go over them after I merge for future reference.

Going over the patch brought up an issue (method contexts) that I'm patching separately. I'm trying to get everything committed tonight.

thejohnfreeman commented 11 years ago

Touchups are in a53b52e5cef8dbcd78c8c997ac9bb15ade4cd8c4. Please review them (there's not very many).

gfoust commented 11 years ago

I intended to make my request against develop--so if I did it against master it was just a user error. Sorry.

A ValidatorFactory is used to build the validation functions used in translations. So when you type

var num$ = hd.translation(num); num$.validate.required().number().range(1, 10);

The expression num$.validate is a ValidatorFactory for num$. The prototype for a ValidatorFactory is hd.validators. The idea is for programmers to be able to add new methods to hd.validators which can then be used when building validation functions (per Jaakko's request).
Therefore, I didn't want a ValidatorFactory to have any fields which could potentially block user functions added to hd.validators; so I made all of its field names begin with an underscore.

Gabe

On 9/7/12 3:26 PM, John Freeman wrote:

  1. Not sure if this was said earlier, but please make pull requests against develop and not master.
  2. Is there a reason the members of ValidatorFactory are prefixed with an underscore?

I'm working on some small touchups to the patch, but there's not much. You can go over them after I merge for future reference.

Going over the patch brought up an issue (method contexts) that I'm patching separately. I'm trying to get everything committed tonight.

— Reply to this email directly or view it on GitHub https://github.com/HotDrink/hotdrink/pull/41#issuecomment-8377693.

thejohnfreeman commented 11 years ago

Ok. They would be good candidates to hide under a "hotdrink prototype" member. I'm trying to make it standard practice across the library:

var HDPROTO = hd.HDPROTO; // I still have to change this constant from its current name of PROTO_NAME
validator[HDPROTO] = {
  incoming: ...
  outgoing: ...
}