Skip to content

Support for Contexts #3

Description

@jeme

In some cases it would be desired to enter a context when writing validation rules, so that we do not repeat our self. e.g.

   When(Any).Then(
                Field("person.name", !Must.Be.NullOrEmpty()) &
                Field("person.familyName", !Must.Be.NullOrEmpty()) &
                Field("person.age", !Must.Be.NullOrEmpty()) &
                Field("person.gender", !Must.Be.NullOrEmpty()) 
                );

Would be replacable by something like: (Syntax not decided)

  using(With("person")) { 
     When(Any).Then(
                Field("name", !Must.Be.NullOrEmpty()) &
                Field("familyName", !Must.Be.NullOrEmpty()) &
                Field("age", !Must.Be.NullOrEmpty()) &
                Field("gender", !Must.Be.NullOrEmpty()) 
                );
  }

To say that each of the following rules are children of the parent "person".

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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