Skip to content

New API #5

@Bobronium

Description

@Bobronium

Let's discuss new vaa api here.

Previously discussed:

  • Make errors list of ErrorObj (Should we make it raisable?);
  • Drop special types for validators in favor of functions and typing.NamedTuple. (done in New validators creation method #3)

I also suggest to:

  • drop is_valid property and threat data as valid if no errors returned;
  • rename cleaned_data to data (cause it shorter) and just assume that is valid (still not sure about this).

New api example:

validator = vaa.get_from(some_scheme)
some_data = {'a': 1}
result = validator(some_data)
result.data
result.errors
# or
data, errors = validator(some_data)

if errors:  # not valid
    ...

To think about:

  • raising exception on errors?
  • if we return errors and data is valid, should we return errors as a empty list or as None (same goes for data)?

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is neededquestionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions