Giter Site home page Giter Site logo

dynamicvalidation's Introduction

DynamicValidation

Object-Tree validation tools.

Experiments in the direction of simple and readable validation of the structure and data of any object tree.

Validation assertions can be either INamedPredicates or NUnit assertion constraints.

Todo

  • Maybe handle recursive data structures by having another List assertion strategy ("all,recurse"?) will assert on matching level, and any children with same name. (this would allow for group->group->group...->item)

Example

Check.Result result = Check.That(MyObject).Identifier.LocalIdentifier[Should.NotBeNull];

if ( ! result.Success) throw new Exception(result.Reason);

The idea is to get the check object, walk the object tree then pass a set of validation predicates into the index.

Then get a result back, success or failure, with a message for failure which is the name of the predicates that failed.

If any part of the object tree is null except the last item then that's a failure with it's own message.

To check each item in an enumerable, you can use

var result = Check.That(subject).container("all")[Should.NotBeNull)];

If the validation needs to check children of an enumerable can define like this:

    Check.That(thing).a.b[Should.HaveAtLeast(1)]
    Check.That(thing).a.b("all").c[Should.NotBeEmpty]
    Check.That(thing).a.b("first").c.d[Should.NotBeEmpty]
    Check.That(thing).a.b("single").c.d[Should.NotBeEmpty]

dynamicvalidation's People

Contributors

i-e-b avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.