ValidationUtils { public static boolean uuidIsValid( String uuid ) { try { UUID.fromString( uuid ); return true; } catch ( IllegalArgumentException ex ) { return false; } }  static boolean expressionIsValidSQl( String filter ); static boolean emailIsValid( String email ); static boolean dateIsValid( String date, Locale locale ); static boolean dateIsValid( String date ); static boolean timeIsValid( String time ); static boolean urlIsValid( String url ); static boolean uuidIsValid( String uuid ); static boolean usernameIsValid( String username ); static boolean passwordIsValid( String password ); static boolean coordinateIsValid( String coordinate ); static boolean bboxIsValid( String bbox ); static String getLongitude( String coordinate ); static String getLatitude( String coordinate ); static Point2D getCoordinatePoint2D( String coordinate ); static String getCoordinate( String longitude, String latitude ); static String dataValueIsValid( String value, DataElement dataElement ); static String dataValueIsValid( String value, ValueType valueType ); static boolean dataValueIsZeroAndInsignificant( String value, DataElement dataElement ); static String commentIsValid( String comment ); static String storedByIsValid( String storedBy ); static boolean isValidHexColor( String value ); static Object getSubstitutionValue( ValueType valueType ); static String normalizeBoolean( String bool, ValueType valueType ); static boolean validateRenderingType( Class<?> clazz, ValueType valueType, boolean optionSet, ValueTypeRenderingType type ); static boolean validateWhatsapp( String whatsapp ); static boolean validateInternationalPhoneNumber( String phoneNumber ); static final ImmutableSet<String> ILLEGAL_SQL_KEYWORDS; }
@Test public void testUuidIsValid() { assertTrue( uuidIsValid( "0b976c48-4577-437b-bba6-794d0e7ebde0" ) ); assertTrue( uuidIsValid( "38052fd0-8c7a-4330-ac45-2c53b3a41a78" ) ); assertTrue( uuidIsValid( "50be5898-2413-465f-91b9-aced950fc3ab" ) ); assertFalse( uuidIsValid( "Jjg3j3-412-1435-342-jajg8234f" ) ); assertFalse( uuidIsValid( "6cafdc73_2ca4_4c52-8a0a-d38adec33b24" ) ); assertFalse( uuidIsValid( "e1809673dbf3482d8f84e493c65f74d9" ) ); }