Advanced Designer Learning Path is now live! Read More

Verify custom field string syntax

Level 3
Verify custom field string syntax

Hi

I've read this article:

custom-fields 

And I was wondering how can I verify the input of String type? I want it to get only version (as example '3.2.1'), and if not, it should throw exception

I guess it should be done thought the python-lib folder, and using the `from packaging import version`

0 Kudos
4 Replies
Dataiker
Dataiker

Hi,

The verification of the content of plugin component parameters can be done in the python backend.
For example, in a custom recipe of a plugin, you can check the parameter value after loading the recipe config (with dataiku.customrecipe.get_recipe_config) and raise errors if needed.

0 Kudos
Level 3
Author

Can you give me example based on my case? assuming this is my JSON:

{
"meta": {
"label": "Version",

"description": "my description",

"icon": "icon-puzzle-piece"
},
"customFields": [
{
"applyToObjects": {
"mode": "ALL"
},
"field": {
"name": "Version",
"label": "Last Bundle Version",
"type": "STRING",
"defaultValue": "1.0.0"
}
}
]
}

now, How can I validate that the input for the `Last Bundle Version` field is in the correct Version Syntax using python packaging? Where I'm adding the code that once someone trying hardcoded to change the value thought the UI (for example to "Test") it throws exception?

0 Kudos
Dataiker
Dataiker

Hi,
Sorry I was referring to plugin parameters instead of custom fields.
For the moment you can't do string validation in the UI and there is no python backend with custom fields components.
You could only check the string when using its value in a future code.

Level 3
Author

I think you should consider also adding type of Version in the supported type.

BTW, if its not supported, why the python-lib folder is there? what it is used for?

Labels (2)
A banner prompting to get Dataiku DSS