background
angularjs' ngmodelcontroller includes ability register:
- parsers: transform raw form field values before passed validation chain.
- validators: pass/fail depending on value parser chain.
- formatters: can transform model value output in form field
all of examples have seen use these perform trivial text manipulation on fields. eg. store uppercased version of text field in model while displaying lower cased version in view.
the sophisticated example i've come across transforms input made of 3 fields single "date" string. but, end result still string.
it seems parser chain used create actual domain specific value object instances, not strings. used centralise validation logic , fix duplication occurs between "model" , "form" (or, left out of model entirely, because made forms responsibility). , keeps strings "at boundary" of system.
question
so, returning object instances common practice haven't come across? , if not, there reason it's bad idea?
Comments
Post a Comment