Manual for Validators and Converters#
CKAN has the validator mechanism to check if the given value is valid. CKAN also comes with converters to transform the given value into a valid value.
Internal Validators and Converters#
- ckanext.data_depositario.converters.remove_blank_wrap(value, context)#
Remove blank and text wrap in the value.
- ckanext.data_depositario.converters.value_string_convert(key, data, errors, context)#
Takes a list of values that is a comma-separated string (in data[key]) and parses values. These are added to the data dict, enumerated. Borrowed from tag_string_convert in CKAN core.
External Validators and Converters#
- if_empty_same_as(name)
Return the value in the
name
field if the provided value is empty.- unicode
Checks that the provided value (if it is present) is a valid unicode string.
- not_empty
Only check if the provided value is empty.
- package_name_validator
Check that no package with the given name already exists and limit the length of the name from 2 characters to 100 characters.
- scheming_required
If the field is required, apply the
not_empty
validator. Otherwise, apply theignore_missing
validator.- scheming_choices
Must be empty or one of the field choices values.
- ignore_missing
By putting
ignore_missing
at the start of the schema list for a field, you can allow users to post a dataset or resource without the field and the dataset or resource will pass validation. But if they post a dataset or resource that does contain the field, then any validators after ignore_missing in the dataset’s or resource’s schema list will be applied.- tag_string_convert
Check that if the tag is a valid unicode string, -, _, or . characters. And limit the length of the tag from 1 characters to 100 characters.
- ignore_empty
Accept the empty string.
- wikidata_keyword
Must be in the form of Python list (e.g.,
["Q1", "Q2"]
) or string (e.g.,"Q1, Q2"
).- scheming_multiple_choice
Must be in the form of Python list (e.g.,
["Q1", "Q2"]
) or string (e.g.,"Q1, Q2"
). And the values must be in the field choices values.- is_positive_integer
Must be a postive integer.
- owner_org_validator
Must be “no project” or an existing project.
- email_validator
Must be in a valid email address.
- remove_whitespace
Remove the leading and trailing whitespace characters in the string.
- if_empty_guess_format
Guess file format if it is empty.
- clean_format
Convert the filename extension to lower case.
Validators and Converters Used for Metadata#
Dataset Level#
Note
Default validators for optional fields: ignore_missing unicode
Basic Information#
Field Name |
Validators and Converters |
---|---|
Title |
|
URL |
|
Description |
Default validators for optional fields |
Data Type |
|
Wikidata Keywords |
|
Tags |
|
Language |
|
Remarks |
Default validators for optional fields |
Spatio-temporal Information#
Field Name |
Validators and Converters |
---|---|
Temporal Resolution |
|
Start Time |
|
End Time |
|
Spatial |
|
X.min |
|
X.max |
|
Y.min |
|
Y.max |
|
Spatial Resolution |
Management Information#
Field Name |
Validators and Converters |
---|---|
License |
Default validators for required fields |
Creator |
Default validators for required fields |
Created Time |
|
Process Step |
Default validators for optional fields |
Project |
|
Contact Person |
Default validators for optional fields |
Contact Person Email |
Resource Level#
Field Name |
Validators and Converters |
---|---|
URL |
|
Name |
Default validators for optional fields |
Description |
Default validators for optional fields |
Character Encoding |
|
Coordinate Systems |
|
Format |