From c2189a78b9dafc237afd3de5f9fc66bc1567eb15 Mon Sep 17 00:00:00 2001 From: Samuel Holland Date: Thu, 17 Aug 2017 03:32:01 -0500 Subject: ConfigEditFragment: Add extremely basic validation Signed-off-by: Jason A. Donenfeld --- app/src/main/java/com/wireguard/config/Config.java | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'app/src/main/java/com/wireguard/config') diff --git a/app/src/main/java/com/wireguard/config/Config.java b/app/src/main/java/com/wireguard/config/Config.java index 9f1dbf4c..3f98cbcb 100644 --- a/app/src/main/java/com/wireguard/config/Config.java +++ b/app/src/main/java/com/wireguard/config/Config.java @@ -127,4 +127,12 @@ public class Config extends BaseObservable sb.append('\n').append(peer); return sb.toString(); } + + public String validate() { + if (name == null || !isNameValid(name)) + return "This configuration does not have a valid name."; + if (iface.getPublicKey() == null) + return "This configuration does not have a valid keypair."; + return null; + } } -- cgit v1.2.3