What’s the longest possible worldwide phone number I should consider in SQL varchar(length) for phone

Assuming you don’t store things like the ‘+’, ‘()’, ‘-‘, spaces and what-have-yous (and why would you, they are presentational concerns which would vary based on local customs and the network distributions anyways), the ITU-T recommendation E.164 for the international telephone network (which most national networks are connected via) specifies that the entire number (including … Read more

Regex Email validation

TLD’s like .museum aren’t matched this way, and there are a few other long TLD’s. Also, you can validate email addresses using the MailAddress class as Microsoft explains here in a note: Instead of using a regular expression to validate an email address, you can use the System.Net.Mail.MailAddress class. To determine whether an email address … Read more

Cross field validation with Hibernate Validator (JSR 303)

Each field constraint should be handled by a distinct validator annotation, or in other words it’s not suggested practice to have one field’s validation annotation checking against other fields; cross-field validation should be done at the class level. Additionally, the JSR-303 Section 2.2 preferred way to express multiple validations of the same type is via … Read more

What’s the valid way to include an image with no src?

Another option is to embed a blank image. Any image that suits your purpose will do, but the following example encodes a GIF that is only 26 bytes – from http://probablyprogramming.com/2009/03/15/the-tiniest-gif-ever <img src=”data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=” width=”0″ height=”0″ alt=”” /> Edit based on comment below: Of course, you must consider your browser support requirements. No support for IE7 … Read more

How to validate an XML file against an XSD file?

The Java runtime library supports validation. Last time I checked this was the Apache Xerces parser under the covers. You should probably use a javax.xml.validation.Validator. import javax.xml.XMLConstants; import javax.xml.transform.Source; import javax.xml.transform.stream.StreamSource; import javax.xml.validation.*; import java.net.URL; import org.xml.sax.SAXException; //import java.io.File; // if you use File import java.io.IOException; … URL schemaFile = new URL(“http://host:port/filename.xsd”); // webapp example … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)