Skip to content

Support for Any and All in Comparison of fields. #6

@jeme

Description

@jeme

Given the example syntax in #5

When("myNumber", Is.Defined()).Then(Field("myNumber", ComparedTo("otherNumber", b => Must.Be.GreaterOrEqualTo((DateTime)b))));

An additional idea would be to allow Any/Some and All to work around the constraint if we where to compare to multiple other values (in arrays):

Something like:

// Given nyNumber, it should be greater than ANY of the others numbers.
When("myNumber", Is.Defined())
    .Then(Field("myNumber", ComparedTo("others[*].number", Any(b => Must.Be.GreaterThan((DateTime)b)))));

// Given myNumber, it should be greater than ALL of the other numbers.
When("myNumber", Is.Defined())
    .Then(Field("myNumber", ComparedTo("others[*].number", All(b => Must.Be.GreaterThan((DateTime)b)))));

It could be considered if a "None" expression here could also make sense, it should be possible to create by a simple negated "Any", so the value would be more in line of how we can express the validation and as a consequence generate descriptions of it.

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