Skip to content

Proper handling of empty attribute when minLength=1 #79

@donaldcampbelljr

Description

@donaldcampbelljr
          Ok, for our desired use case, this causes eido validation to fail:
    _validate_sample_object(
  File "/home/drc/GITHUB/looper/master/looper/venv/lib/python3.10/site-packages/eido/validation.py", line 100, in _validate_sample_object
    _validate_object(sample.to_dict(), sample_schema_dict)
  File "/home/drc/GITHUB/looper/master/looper/venv/lib/python3.10/site-packages/eido/validation.py", line 47, in _validate_object
    instance_name = error.instance[sample_name_colname]
IndexError: string index out of range

This is because error.instance is empty and sample_name_colname=False

However, if you do have some value in the field such as 'h' but the minLength: 2, we see a better message:

Error: EidoValidationError (Validation failed): {"'h' is not valid under any of the given schemas": [{'type': "'h' is not valid under any of the given schemas", 'message': "'h' is not valid under any of the given schemas on instance h", 'sample_name': 'h'}]}
["'h' is not valid under any of the given schemas"]

Originally posted by @donaldcampbelljr in pepkit/looper#523 (comment)

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