Skip to content

Implement Operation Declaration Validation #2

@lordlogo2002

Description

@lordlogo2002

Description:

Currently, the calculator program supports operators that accept only two arguments. However, we want to introduce a change that allows for operators with multiple or single arguments. To implement this, we need to validate the operation declarations to ensure they follow the desired #1 format.

Task:

Implement a method to validate operation declarations and ensure they adhere to the required format.

Validation Requirements:

The operation declaration should be a dictionary with a valid tag as the key.

  1. The value associated with the tag should be a dictionary containing the following keys: "title", "symbol", "args", "action", and "result-name".
  2. The "title" key should have a non-empty string value.
  3. The "symbol" key should have a non-empty string value.
  4. The "args" key should have a tuple value containing at least one non-empty string argument.
  5. The "action" key should have a callable object assigned.
  6. The "result-name" key should have a non-empty string value.

Acceptance Criteria:

Implement a method named validate_operation_declaration that takes an operation declaration dictionary and the tag str as input and raise a KeyError with details about the error if any ocures. If its right formated just return None.
The method should validate the operation declaration according to the requirements mentioned above.
If any of the validation requirements fail, the method should provide a clear error message indicating the specific issue encountered.
Write unit tests to verify the correctness of the validate_operation_declaration method.
Ensure the method is properly documented with type hints and descriptive docstrings.

Deliverables:

  • Implement the validate_operation_declaration method.
  • Write unit tests to validate the behavior of the method.
  • Document the method with type hints and descriptive docstrings.
  • Update the README or documentation to include information on how to use the validate_operation_declaration method.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions