mindplay.dk Posted June 26, 2013 Share Posted June 26, 2013 We have an increasing number of Fieldtypes and Inputfields, and I just had a realization: validation is baked into Fieldtypes and Inputfields, wherever it fits. That seems wrong? Or at best, rather arbitrary - these concerns seem to get baked in wherever they might fit. So now we end up with things like InputfieldEmail, InputfieldURL and FieldtypeTextUnique, all of which have various types of validations baked into them. Well, now suppose I want a field that validates both as unique and as an e-mail address? That's two validations. I would need to write another class, and even then I might have to duplicate some code to make that happen. Basically, any arbitrary combination of validations would require a new type. Have you thought about adding a validation framework of some sort? Allowing for multiple validations on the same Field, configurable error-messages, etc.? This might reduce the number of Inputfields and Fieldtypes considerably? A lot of fields are just some variety of a text-field, with different validation - it would be nice to be able to apply validations such as uniqueness to either e-mail, URL, integer, Page-reference, etc. It would also be nice to be able to write site-specific validations and reuse them across multiple fields on some sites. A configurable general-purpose validator for regular expressions would be another possibility - this could be extremely useful, for example when a field should accept URLs referencing a specific site, like YouTube or Vimeo. Componentized, modular, and configurable validation is something most major CMS have - is something like this in the stars for ProcessWire? Link to comment Share on other sites More sharing options...
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!Register a new account
Already have an account? Sign in here.Sign In Now