FELIX-3183 Fail validation if a required value is missing from an attribute

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1187704 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/metatype/src/main/java/org/apache/felix/metatype/AD.java b/metatype/src/main/java/org/apache/felix/metatype/AD.java
index f141edc..5dccf82 100644
--- a/metatype/src/main/java/org/apache/felix/metatype/AD.java
+++ b/metatype/src/main/java/org/apache/felix/metatype/AD.java
@@ -56,6 +56,13 @@
      */
     public static final String VALIDATE_LESS_THAN_MINIMUM = "%less than minimum";
 
+    /**
+     * The message returned from the {@link #validate(String)} method if the
+     * value is null or cannot be converted to an attribute value and a value
+     * is {@link #isRequired() required} (value is "%missing required value").
+     */
+    public static final String VALIDATE_MISSING = "%missing required value";
+
     private String id;
     private String name;
     private String description;
@@ -174,6 +181,11 @@
         Comparable value = convertToType( valueString );
         if ( value == null )
         {
+            if ( isRequired() )
+            {
+                return VALIDATE_MISSING;
+            }
+
             return ""; // accept null value
         }