Skip to content

Commit

Permalink
Merge pull request #4014 from open-formulieren/issue/3977-add-missing…
Browse files Browse the repository at this point in the history
…-submission-context

✨ [#3977] Add submission context to formio data serializer
  • Loading branch information
sergei-maertens authored Mar 15, 2024
2 parents 571b1ae + b4ccdb2 commit 80f04ee
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/openforms/submissions/api/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,11 @@ def validate(self, attrs: dict):
assert step.form_step
components = step.form_step.form_definition.configuration["components"]

step_data_serializer = build_serializer(components, data=data)
step_data_serializer = build_serializer(
components,
data=data,
context={"submission": submission},
)
if not step_data_serializer.is_valid():
errors = step_data_serializer.errors

Expand Down
16 changes: 16 additions & 0 deletions src/openforms/tests/e2e/test_input_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,22 @@ def test_regex_house_number_addition(self):
expected_ui_error="Huisnummertoevoeging mag enkel alfanumerieke karaketers zijn.",
)

def test_kvk_number_validation_plugin(self):
component: Component = {
"type": "textfield",
"key": "chamberOfCommerce",
"label": "KVK nummer",
"validate": {
"plugins": ["kvk-kvkNumber"],
},
}

self.assertValidationIsAligned(
component,
ui_input="aaaa", # deliberate to trigger the non-network validation
expected_ui_error="Waarde moet numeriek zijn.",
)


class SingleEmailTests(ValidationsTestCase):
def test_required_field(self):
Expand Down

0 comments on commit 80f04ee

Please sign in to comment.