Add a facility for contact name validation
This commit is contained in:
		
							
								
								
									
										32
									
								
								src/main/java/envoy/util/Bounds.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								src/main/java/envoy/util/Bounds.java
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,32 @@
 | 
				
			|||||||
 | 
					package envoy.util;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.util.regex.Pattern;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * Implements contact name validation.
 | 
				
			||||||
 | 
					 * <p>
 | 
				
			||||||
 | 
					 * Project: <strong>envoy-common</strong><br>
 | 
				
			||||||
 | 
					 * File: <strong>Bounds.java</strong><br>
 | 
				
			||||||
 | 
					 * Created: <strong>25.06.2020</strong><br>
 | 
				
			||||||
 | 
					 * 
 | 
				
			||||||
 | 
					 * @author Kai S. K. Engelbart
 | 
				
			||||||
 | 
					 * @since Envoy Common v0.1-beta
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					public class Bounds {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						private Bounds() {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
						 * The regular expression against which contact names should be validated.
 | 
				
			||||||
 | 
						 * 
 | 
				
			||||||
 | 
						 * @since Envoy Common v0.1-beta
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						public static final Pattern CONTACT_NAME_PATTERN = Pattern.compile("^\\w[a-zA-Z0-9-]{2,15}$");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
						 * @param contactName the contact name to validate
 | 
				
			||||||
 | 
						 * @return {@code true} if the given contact name is valid
 | 
				
			||||||
 | 
						 * @since Envoy Common v0.1-beta
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						public static boolean isValidContactName(String contactName) { return CONTACT_NAME_PATTERN.matcher(contactName).matches(); }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
		Reference in New Issue
	
	Block a user