On 13/08/16 18:28, Marco Pivetta wrote: > A "NI" or "Email address" concept is only a string at low level. Yes ... but where do you store the flag such as "NI" ...
> It is well known/accepted that such concepts should be turned into > simple objects instead, so that you can actually use type-signatures to > type-hint against NI/Email. Just about every framework builds it's own set of fundamental sigs or re-works the interface to field types on PDO and there is no simple standard which having them added at the basic var level would provide. $ni_no is a string type UK_NI ... > This avoids having to re-validate for data-integrity and correctness of > a value at every layer of your architecture. I've waffled on about where I am currently TRYING to get to, and actually it is starting to pull together all be it with the need for proprietary code at a key level. The heckling from other replies is more along the lines that you HAVE to revalidate at every layer, so while the browser validation ensures what was keyed in is correct, you have to assume some yob has messed with the post data and re-run the SAME validation in the post array. If all of this is keyed to the SQL schema as well, then THAT validation populates the database insert and no more checks are needed. > Add `__toString` to them and they even behave like they did before > (strings). Or replace the return with a correctly escaped string for the variables destination. $ni_no->__tostring simply returns the raw text string if the content is valid ... and if the user switches on 'strict' they get an exception if the variable is not valid, or I would prefer simply NULL ... -- Lester Caine - G8HFL ----------------------------- Contact - http://lsces.co.uk/wiki/?page=contact L.S.Caine Electronic Services - http://lsces.co.uk EnquirySolve - http://enquirysolve.com/ Model Engineers Digital Workshop - http://medw.co.uk Rainbow Digital Media - http://rainbowdigitalmedia.co.uk -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php