-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
... to be up to date with the current OF standard Only implementation is changed in this commit, tests will follow
- Loading branch information
Showing
7 changed files
with
102 additions
and
116 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
from abc import ABC, abstractmethod | ||
from typing import ClassVar, Generic, TypeVar | ||
|
||
from rest_framework import serializers | ||
|
||
from openforms.plugins.plugin import AbstractBasePlugin | ||
from openforms.submissions.models import Submission | ||
|
||
T = TypeVar("T") | ||
"""A type variable representing the type of the value being validated by the plugin.""" | ||
|
||
|
||
class StringValueSerializer(serializers.Serializer): | ||
"""A default serializer that accepts ``value`` as a string.""" | ||
|
||
value = serializers.CharField() | ||
|
||
|
||
class BasePlugin(ABC, AbstractBasePlugin, Generic[T]): | ||
|
||
value_serializer: ClassVar[type[serializers.BaseSerializer]] = StringValueSerializer | ||
"""The serializer to be used to validate the value.""" | ||
|
||
for_components: ClassVar[tuple[str, ...]] = tuple() | ||
"""The components that can make use of this validator.""" | ||
|
||
@property | ||
def is_enabled(self) -> bool: | ||
# TODO always enabled for now, see: https://github.com/open-formulieren/open-forms/issues/1149 | ||
return True | ||
|
||
@abstractmethod | ||
def __call__(self, value: T, submission: Submission) -> bool: | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.