[SEBA-543] Fixing the modeldef API to report required fields

Change-Id: Ia677765e3de10941f6e7ecec15fa85175bc9c0db
diff --git a/lib/xos-genx/xos-genx-tests/test_gui.py b/lib/xos-genx/xos-genx-tests/test_gui.py
new file mode 100644
index 0000000..e40a2de
--- /dev/null
+++ b/lib/xos-genx/xos-genx-tests/test_gui.py
@@ -0,0 +1,50 @@
+# Copyright 2017-present Open Networking Foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+from __future__ import absolute_import
+import unittest
+from xosgenx.generator import XOSProcessor, XOSProcessorArgs
+from xosgenx.jinja2_extensions import xproto_validators
+from helpers import XProtoTestHelpers
+
+
+class XProtoGuiTest(unittest.TestCase):
+    def setUp(self):
+        self.target = XProtoTestHelpers.write_tmp_target(
+            """
+            {%- for m in proto.messages %}
+            {% for f in m.fields %}
+                {{ xproto_validators(f) }}
+            {% endfor -%}
+            {% endfor -%}
+            """
+        )
+
+    def test_validators(self):
+        field = {
+            'modifier': 'required',
+            'type': 'string',
+            'options': {
+                'max_length': '200',
+                'modifier': 'required'
+            }
+        }
+
+        res = xproto_validators(field)
+
+        self.assertDictEqual(res[0], {'int_value': 200, 'name': 'maxlength'})
+        self.assertDictEqual(res[1], {'bool_value': True, 'name': 'required'})
+
+if __name__ == "__main__":
+    unittest.main()
\ No newline at end of file
diff --git a/lib/xos-genx/xosgenx/jinja2_extensions/gui.py b/lib/xos-genx/xosgenx/jinja2_extensions/gui.py
index a48d95a..476548b 100644
--- a/lib/xos-genx/xosgenx/jinja2_extensions/gui.py
+++ b/lib/xos-genx/xosgenx/jinja2_extensions/gui.py
@@ -64,6 +64,7 @@
 
 
 def xproto_validators(f):
+
     # To be cleaned up when we formalize validation in xproto
     validators = []
 
@@ -92,7 +93,7 @@
 
     # required validator
     try:
-        required = f["options"]["blank"] == "False" and f["options"]["null"] == "False"
+        required = f["modifier"] == "required"
         if required:
             validators.append({"name": "required", "bool_value": required})
     except KeyError: