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 the ignore_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

Default validators for required fields: not_empty unicode

Basic Information#

Field Name

Validators and Converters

Title

if_empty_same_as(name) unicode

URL

not_empty unicode package_name_validator

Description

Default validators for optional fields

Data Type

scheming_required scheming_multiple_choice

Wikidata Keywords

wikidata_keyword

Tags

ignore_missing tag_string_convert

Language

value_string_convert scheming_multiple_choice

Remarks

Default validators for optional fields

Spatio-temporal Information#

Field Name

Validators and Converters

Temporal Resolution

scheming_required scheming_choices

Start Time

ignore_empty

End Time

ignore_empty end_time_validator

Spatial

ignore_empty json_validator remove_blank_wrap

X.min

ignore_empty long_validator

X.max

ignore_empty long_validator

Y.min

ignore_empty lat_validator

Y.max

ignore_empty lat_validator

Spatial Resolution

ignore_empty positive_float_validator

Management Information#

Field Name

Validators and Converters

License

Default validators for required fields

Creator

Default validators for required fields

Created Time

ignore_empty date_validator

Process Step

Default validators for optional fields

Project

owner_org_validator unicode

Contact Person

Default validators for optional fields

Contact Person Email

ignore_missing unicode email_validator

Resource Level#

Field Name

Validators and Converters

URL

ignore_missing unicode remove_whitespace

Name

Default validators for optional fields

Description

Default validators for optional fields

Character Encoding

scheming_required scheming_choices

Coordinate Systems

ignore_empty is_positive_integer

Format

if_empty_guess_format ignore_missing clean_format unicode