Skip to content

Instance method validation callbacks are broken #131

@Blacksmoke16

Description

@Blacksmoke16

Using the example from https://athenaframework.org/Validator/Constraints/Callback/#Athena::Validator::Constraints::Callback--instance-methods:

> 1 |
> 2 |
> 3 |         obj.validate
^-------
Error: wrong number of arguments for 'Example#validate' (given 0, expected 2)

Overloads are:
- Example#validate(context : AVD::ExecutionContextInterface, payload : Hash(String, String) | ::Nil)

Debugging the macro logic:

# Add property constraints

# Add getter constraints

class_metadata.add_getter_constraint(
AVD::Metadata::GetterMetadata(T, 1).new("validate"),
Athena::Validator::Constraints::Callback.new # Default argument

)

# Add callback constraints

It seems to be adding the method as a getter and not as a callback method.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions