Skip to content

Request - Error response to indicate field must be empty when not meeting conditions #357

@edsu7

Description

@edsu7

Summary of request

When given the following conditions :

"restrictions": [
    {
        "if": {
            "conditions": [
                {
                    "case": "any",
                    "fields": [
                        "insdc_project_accession"
                    ],
                    "match": {
                        "regex": "^(?!.*[\\x09\\x0A\\x0D])(?:\\S+(?: \\S+)*)?$"
                    }
                },
                {
                    "fields": [
                        "insdc_project_accession"
                    ],
                    "match": {
                        "codeList": [
                            "Not Applicable [GENEPIO:0001619]",
                            "Missing [GENEPIO:0001618]",
                            "Not Collected [GENEPIO:0001620]",
                            "Not Provided [GENEPIO:0001668]",
                            "Restricted Access [GENEPIO:0001810]"
                        ]
                    }
                }
            ],
            "case": "any"
        },
        "then": {
            "required": true
        },
        "else": {
            "empty": true
        }

Field must match conditionA or B else left empty.

If the value does not match A or B, the following error is returned:

INVALID_BY_RESTRICTION - Field: 'sampling_event_id' - Value: 'Sample S2C_Apr7' - Details: 'This field must be empty but was provided a value'

While technically correct, the error can confuse user. Lack of info to explain why the value should be empty.

Details

N/A

Desired solution

Something more informative e.g.

INVALID_BY_RESTRICTION - Field: 'sampling_event_id' - Value: 'Sample S2C_Apr7' - Details: 'This field must be empty as it did not satisfy criteria:
1) INVALID_BY_REGEX - did not meet regex "^(?!.*[\\x09\\x0A\\x0D])(?:\\S+(?: \\S+)*)?$"
2) INVALID_BY_CODELIST' - did not meet codeList [....]

Additional context

N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions