Repository: codingedward/flask-sieve

Issue:
Custom Validation Error format Issue
As per documentation error response default format is 

    success: False,
    message: 'Validation error',
    errors: {
        'email': [
            'The email is required.',
            'The email must be a valid email address.'
        ],
        'password': [
            'The password confirmation does not match.'
        ]
    }
}

**But I am receiving below given. There is no success: false and message : validation errors**

{
  "email": [
    "The email field is required.", 
    "The email must be a valid email address."
  ], 
  "firstName": [
    "The firstName field is required.", 
    "The firstName may only contain letters and numbers."
  ], 
  "lastName": [
    "The lastName field is required.", 
    "The lastName may only contain letters and numbers."
  ]
}


Comments:

Patch:
diff --git a/flask_sieve/exceptions.py b/flask_sieve/exceptions.py
index d5c6dc7..088ead6 100644
--- a/flask_sieve/exceptions.py
+++ b/flask_sieve/exceptions.py
@@ -13,7 +13,7 @@ def register_error_handler(app):
             'errors': ex.errors
         }
 
-        if app.config.get('SIEVE_INCLUDE_SUCCESS_KEY'):
+        if app.config.get('SIEVE_INCLUDE_SUCCESS_KEY', True):
             response['success'] = False
 
         if app.config.get('SIEVE_RESPONSE_WRAPPER'):
diff --git a/watch.sh b/watch.sh
index 7c86b5b..daaf9ad 100755
--- a/watch.sh
+++ b/watch.sh
@@ -1,3 +1,3 @@
 #!/bin/bash
 
-watchman-make -p "**/*.py" --run "rm .coverage; nosetests --with-coverage --cover-package flask_sieve"
+watchman-make -p "**/*.py" --run "rm .coverage; nosetests --nocapture --with-coverage --cover-package flask_sieve"


Test patch:
diff --git a/tests/test_exceptions.py b/tests/test_exceptions.py
index a5abf83..ff698a3 100644
--- a/tests/test_exceptions.py
+++ b/tests/test_exceptions.py
@@ -33,6 +33,19 @@ class TestErrorHandler(unittest.TestCase):
         self.assertEqual(422, status)
         self.assertIn('Test error', str(response.get_json()))
 
+    def test_default_response_message(self):
+        app = Flask(__name__)
+        register_error_handler(app)
+        self.assertIn(ValidationException, app.error_handler_spec[None][None])
+        errors = {'field': 'Test error'}
+
+        with app.app_context():
+            response, status = app.error_handler_spec[None][None][ValidationException](
+                ValidationException(errors)
+            )
+        self.assertEqual(400, status)
+        self.assertIn('Validation error', str(response.get_json()))
+
     def test_configuring_response_message(self):
         app = Flask(__name__)
         msg = "Only Chuck Norris can submit invalid data!"
@@ -63,7 +76,35 @@ class TestErrorHandler(unittest.TestCase):
         self.assertEqual(400, status)
         self.assertTrue('success' in response.get_json())
 
-    def test_keeping_removing_message(self):
+    def test_keeping_success_message(self):
+        app = Flask(__name__)
+        app.config['SIEVE_INCLUDE_SUCCESS_KEY'] = True
+
+        register_error_handler(app)
+        self.assertIn(ValidationException, app.error_handler_spec[None][None])
+        errors = {'field': 'Test error'}
+
+        with app.app_context():
+            response, status = app.error_handler_spec[None][None][ValidationException](
+                ValidationException(errors)
+            )
+        self.assertEqual(400, status)
+        self.assertTrue('success' in response.get_json())
+
+    def test_having_success_message_by_default(self):
+        app = Flask(__name__)
+        register_error_handler(app)
+        self.assertIn(ValidationException, app.error_handler_spec[None][None])
+        errors = {'field': 'Test error'}
+
+        with app.app_context():
+            response, status = app.error_handler_spec[None][None][ValidationException](
+                ValidationException(errors)
+            )
+        self.assertEqual(400, status)
+        self.assertTrue('success' in response.get_json())
+
+    def test_removing_success_message(self):
         app = Flask(__name__)
         app.config['SIEVE_INCLUDE_SUCCESS_KEY'] = False
 
diff --git a/tests/test_rules_processor.py b/tests/test_rules_processor.py
index eeafd0f..15cf856 100644
--- a/tests/test_rules_processor.py
+++ b/tests/test_rules_processor.py
@@ -1039,12 +1039,14 @@ class TestRulesProcessor(unittest.TestCase):
         self._assert(rules, request, True)
 
     def _assert(self, rules, request, passes):
-        p = self.parser
-        v = self.processor
-        v.set_request(request)
-        p.set_rules(rules)
-        v.set_rules(p.parsed_rules())
-        self.assertTrue(v.passes() if passes else v.fails())
+        self.processor.set_request(request)
+        self.parser.set_rules(rules)
+        self.processor.set_rules(self.parser.parsed_rules())
+        if passes:
+            self.assertTrue(self.processor.passes())
+        else:
+            self.assertTrue(self.processor.fails())
+
 
     def tearDown(self):
         self.stream.close()