These are chat archives for canjs/canjs

27th
May 2016
Juan Orozco
@Macrofig
May 27 2016 14:17
@web-mech im catching up with this thread, i can likely help explain a few things
Michael Price
@web-mech
May 27 2016 14:19
@Macrofig that’d be much appreciated
Juan Orozco
@Macrofig
May 27 2016 14:40
@cherifGsoul Regarding having can-valdiate bundled, it should already be? It comes when npm installed. (sorry for the super late reply)
@minsooshin Did you figure out your issue? Where you able to get Bootstrap and can-validate to work properly?
Juan Orozco
@Macrofig
May 27 2016 14:48
@web-mech ok, re this, any validation prop can be a function. Can-validate converts that into a compute with the current view model instance as the context. So, on every set, that compute is called. The compute is expected to return a validate.js validation object... which could be, as you likely already know, just true or something like {message: "^My custom message"}
Using this, you could check another property in your view model and return false when you don't want validation to happen.
Perhaps we can add a feature that does a preflight check before any validation. So, if you provide something like preFlight: function () { return this.attr('shouldValidate')} in the validate object, can-validate will know when it should/should not validate.
As for this, I only know this to happen when you run the validate method on the instance. I have an issue to fix canjs/can-validate#27 that. But it shouldn't happen on set of a value.
Juan Orozco
@Macrofig
May 27 2016 15:17
@minsooshin Also re your test issue, weird that installing can-validate would do that. Maybe has something to do with dependency i'm using? I'll make sure i'm on latest of everything. Without any more context, I'm suspicious of Babel or Steal since it seems ES6 related.
Michael Price
@web-mech
May 27 2016 17:08
Right on @Macrofig . But it does indeed look like this is null during set of another value. null_on_set
This is being called when i set 1.selection, without calling validate on the instance of the map.
I kind of like the idea of the preFlight solution, Ideally my maps wouldn’t have any errors until validate is explicitly called
and the initial set of a map shouldn’t trigger validation computes
Juan Orozco
@Macrofig
May 27 2016 17:48
@web-mech Looking at the screenshot, do you mean that when you set 1.date the required function is called? Is the value of selection important for context of your issue? Either way, based on what I see, this should be the viewModel and yet it isn't. I'll look into it and get back to you.
Michael Price
@web-mech
May 27 2016 17:49
@Macrofig when i set1.selection the required compute is called for 1.date
1.date is only required if 1.selection is set to 1
Juan Orozco
@Macrofig
May 27 2016 17:49
@web-mech oh super weird.
I mean, it is weird that it calls the validate methods of a completely different property.
ohhhh
I was turned about. I'm getting it now. So, you set 1.selection and the compute for 1.date's required validation is fired off.
Michael Price
@web-mech
May 27 2016 17:52
its a compute though, so i thought that was intended. However, this behavior makes my ui display errors prematurely . I change 1.selection and 2.date shows errors immediately
right
Juan Orozco
@Macrofig
May 27 2016 17:53
The behavior is correct but this's value is not.
Michael Price
@web-mech
May 27 2016 17:53
if i could get that far i’d be ok, for now i have to reference the map from a higher scope to reliably compute required
Juan Orozco
@Macrofig
May 27 2016 17:54
do you have this in a jsbin that I can play with?
Michael Price
@web-mech
May 27 2016 17:55
i can set one up
Juan Orozco
@Macrofig
May 27 2016 17:55
that would be awesome, thank you
Adam L Barrett
@BigAB
May 27 2016 18:56

Are...

can.batch.start();
appState.attr('cart', cart);
appState.attr('pageName', 'checkout');
appState.attr('stepName', nextStep);
appState.attr('PAYPAL_PAYMENT_CONFIRMED', paypalConfirmed);
can.batch.stop();

and

appState.attr({
  'cart': cart,
  'pageName': 'checkout',
  'stepName': nextStep,
  'PAYPAL_PAYMENT_CONFIRMED': paypalConfirmed
});

...functionally equivilant? Like does using the object set in attr batch the changes automatically?