Function validate_fields

Synopsis

def validate_fields(config)

Description

Validates that fields has a value

Source

Lines 26-40 in anyfig/fields.py.

def validate_fields(config):
  ''' Validates that fields has a value '''
  for key, val in vars(config).items():
    if type(val) is InterfaceField:  # Don't check InputField or ConstantField
      err_msg = (
        f"Missing value for '{key}' in config '{type(config).__name__}'. "
        "Set a value or change the type to 'anyfig.cli_input' to allow input arguments without default values"
      )
      assert hasattr(val, 'value'), err_msg

    # Resolve nested configs
    if is_config_class(val):
      validate_fields(val)







Add Discussion as Guest

Log in