These are chat archives for jdubray/sam
As I get into a real world application using SAM, I find myself rarely doing significant processing in my model.present function. I always just accept the incoming data unchallenged from some action and assign it to the model. In my state.representation function I then just check for various flags that will have been set and either repaint snippets of html or refresh the whole app. I notice this comment in some of the simple skeleton samples : " //Logic that accepts or rejects the proposed values"...
I have a form that needs to validate that the user has agreed to the terms and conditions on clicking of a submit button.
My approach is to fire an action on click of the button; present the form data to the model, assign the data to the model , check for missing or unassigned value in the model (that the checkbox would have represented) in the state machine; re-render a show an error message; turn the model flag off in NAP().
does this sound like an ok way to handle the process?
Should I be making use of the model.present function to perform data validation?
Should i being doing validation differently?
@srconklin there are two types of validation:
You should implement activity level validations in the action and domain validations in the model. Encapsulating mutation in the model also helps with concurrency, especially in the case when the action would enrich the user event with an API query.