so I went ahead and built that module I alluded to below. It can be found at my github:
- http://diddledan.github.io/validate-string/ for the pretties (docs), and - https://github.com/diddledan/validate-string for the codes. On 19 May 2015 at 03:32, Daniel Llewellyn <[email protected]> wrote: > Just musing to myself I wondered if there exists currently or on the > roadmap the ability to specify a set of values a particular property may > accept. This would be similar to other languages' `enum` type where you > specify up-front all the possible values and the implementation refuses to > accept things outside of those values. Another idea is a regular expression > validator on incoming values. My idea is that if a component's property is > set to an invalid value by one of these two validations then the component > code we write ourselves is never notified of the change and it is silently > ignored. This would allow component authors to be sure that values they > receive are correct without having to write boilerplate to actually verify > that fact. > > Thinking about a possible implementation I suppose a validator-proxy > component could be created which encapsulates all the required validation > in generalised terms which takes an input value, a default, and either a > regex or list of accepted values and has an output property which will only > ever contain normalised values. > > Then we can even create a series of known-good intermediate > implementations of the validator-proxy which contains pre-build validations > for things like css colours, telephone numbers........ etc. which just take > a single input and give a single validated output without the requirement > to write the regex every time an author wants a common validation. > > In fact I might just go ahead and write that component while I'm faffing > around... > > P.S. 4am coding is always good for these random ideas! Oh it's nearly 4am > (3:30) now :-p > > Follow Polymer on Google+: plus.google.com/107187849809354688692 > --- > You received this message because you are subscribed to the Google Groups > "Polymer" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/polymer-dev/35c3ddaf-ea44-490b-8821-513585c45b7e%40googlegroups.com > <https://groups.google.com/d/msgid/polymer-dev/35c3ddaf-ea44-490b-8821-513585c45b7e%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- Daniel Llewellyn Bowl Hat Follow Polymer on Google+: plus.google.com/107187849809354688692 --- You received this message because you are subscribed to the Google Groups "Polymer" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/polymer-dev/CABtuYwdRv3qBbpKkph_T-wAFmzBZWqKFzytxOCQTwDaQSQhXHw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
