opendrift.models.openoil.adios.models.common.validators

Module Contents

Classes

EnumValidator

validator for Enum values: a value that can only be one of a set

FloatRangeValidator

Validator for float values that can only be a given range

YearValidator

Validator for float values that can only be a given range

class opendrift.models.openoil.adios.models.common.validators.EnumValidator(valid_items, err_msg, case_insensitive=False)[source]

validator for Enum values: a value that can only be one of a set

Parameters:
  • valid_items – list of valid items – can be anything that an in test will work for.

  • err_msg – The error message that should be used on failure. Should be a format string that takes two parameters: item and valid_items

  • case_insensitive=False – whether you want the test to be case-insensitive. Only works for string values, of course.

__call__(item)[source]
class opendrift.models.openoil.adios.models.common.validators.FloatRangeValidator(min_value, max_value, err_msg=None)[source]

Validator for float values that can only be a given range

range is inclusive (<= and >=)

Parameters:
  • min – minimum value allowed

  • max – maximum value allowed

  • err_msg

    The error message that should be used on failure. Should be a format string that takes three parameters: default is:

    ”ValidationError: {} is not between {} and {}”

__call__(value)[source]
class opendrift.models.openoil.adios.models.common.validators.YearValidator(min_year, max_year, err_msg=None)[source]

Validator for float values that can only be a given range

range is inclusive (<= and >=)

Parameters:
  • min – minimum year allowed

  • max – maximum year allowed

  • err_msg

    The error message that should be used on failure. Should be a format string that takes three parameters: default is:

    ”ValidationError: {} is not between {} and {}”

__call__(value)[source]