-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Flexible format validations #360
Comments
/cc @winged Can you share some insights on the regex question? |
I like the idea, however I wouldn't use plain regex, but JEXL instead. The data structure and API/query is a good idea. We could have some built-in validators (hmm regarding filename: validators.py, whaddya think?) and let the users extend it via extension points. Then we'd have a bunch of JEXL validators available to the users via API. Those could be executed in frontend and in backend as well. Why would I chose JEXL instead of plain regex? Maybe you have a validation of a question in the context of another question, for example your chimney height must be in relation to the overall height of the roof etc. What's also needed is a (localized) error message to be displayed in case the validation fails, along with the possibility to add multiple validators to a field. So, we'd have, as a summary:
|
Great idea 💡!
When discussing this with @czosel, we decided to go with plain regex as a start and will switch to JEXL as the need arises. EDIT: Or better call it |
This commit adds flexible format validators. There is one new query: `all_format_validators` that enables querying all available format validators. A text- or textarea-question can have one or multiple format_validators assigned. When querying a question, there is a new `FormatValidatorsConnection`, containing all FormatValidator-objects assigned on the question. For this there is a new `QuestionValidator` that ensures, referenced format_validators exist. `translate_value()` has been moved to `core.utils`, as this is used in the `data_source`- and `form`-app. There is a new extension-point `format_validators.py`. When adding the tests for this, it became obvious, that there was something wrong with the parameters for `DataSource`. As I was touching those tests anyway, I fixed this as well. Added commented out extension volume to docker-compose.yml. Also added forgotten data_sources extension volume. Additionally this commit also cleans up the snapshots for document and question as there were quite a lot old unused snapshots. Closes projectcaluma#360
This commit adds flexible format validators. There is one new query: `all_format_validators` that enables querying all available format validators. A text- or textarea-question can have one or multiple format_validators assigned. When querying a question, there is a new `FormatValidatorsConnection`, containing all FormatValidator-objects assigned on the question. For this there is a new `QuestionValidator` that ensures, referenced format_validators exist. `translate_value()` has been moved to `core.utils`, as this is used in the `data_source`- and `form`-app. There is a new extension-point `format_validators.py`. When adding the tests for this, it became obvious, that there was something wrong with the parameters for `DataSource`. As I was touching those tests anyway, I fixed this as well. Added commented out extension volume to docker-compose.yml. Also added forgotten data_sources extension volume. Additionally this commit also cleans up the snapshots for document and question as there were quite a lot old unused snapshots. Closes projectcaluma#360
This commit adds flexible format validators. There is one new query: `all_format_validators` that enables querying all available format validators. A text- or textarea-question can have one or multiple format_validators assigned. When querying a question, there is a new `FormatValidatorsConnection`, containing all FormatValidator-objects assigned on the question. For this there is a new `QuestionValidator` that ensures, referenced format_validators exist. `translate_value()` has been moved to `core.utils`, as this is used in the `data_source`- and `form`-app. There is a new extension-point `format_validators.py`. When adding the tests for this, it became obvious, that there was something wrong with the parameters for `DataSource`. As I was touching those tests anyway, I fixed this as well. Added commented out extension volume to docker-compose.yml. Also added forgotten data_sources extension volume. Additionally this commit also cleans up the snapshots for document and question as there were quite a lot old unused snapshots. Closes projectcaluma#360
This commit adds flexible format validators. There is one new query: `all_format_validators` that enables querying all available format validators. A text- or textarea-question can have one or multiple format_validators assigned. When querying a question, there is a new `FormatValidatorsConnection`, containing all FormatValidator-objects assigned on the question. For this there is a new `QuestionValidator` that ensures, referenced format_validators exist. `translate_value()` has been moved to `core.utils`, as this is used in the `data_source`- and `form`-app. There is a new extension-point `format_validators.py`. When adding the tests for this, it became obvious, that there was something wrong with the parameters for `DataSource`. As I was touching those tests anyway, I fixed this as well. Added commented out extension volume to docker-compose.yml. Also added forgotten data_sources extension volume. Additionally this commit also cleans up the snapshots for document and question as there were quite a lot old unused snapshots. Closes projectcaluma#360
This commit adds flexible format validators. There is one new query: `all_format_validators` that enables querying all available format validators. A text- or textarea-question can have one or multiple format_validators assigned. When querying a question, there is a new `FormatValidatorsConnection`, containing all FormatValidator-objects assigned on the question. For this there is a new `QuestionValidator` that ensures, referenced format_validators exist. `translate_value()` has been moved to `core.utils`, as this is used in the `data_source`- and `form`-app. There is a new extension-point `format_validators.py`. When adding the tests for this, it became obvious, that there was something wrong with the parameters for `DataSource`. As I was touching those tests anyway, I fixed this as well. Added commented out extension volume to docker-compose.yml. Also added forgotten data_sources extension volume. Additionally this commit also cleans up the snapshots for document and question as there were quite a lot old unused snapshots. Closes projectcaluma#360
Form validations typically include format validations for fields things like emails, social security numbers, credit card and phone numbers, etc.
After discussing with @kaldras, we propose adding a new feature which functions similarly to #320 for this:
format-validations.py
(maybe find better name to avoid confusion withvalidations.py
)allFormatValidations
which will be used in the form builder UIformatValidation
toTextQuestion
,IntegerQuestion
,FloatQuestion
form/validators.py
The text was updated successfully, but these errors were encountered: