GithubHelp home page GithubHelp logo

jameskmonger / courtroom Goto Github PK

View Code? Open in Web Editor NEW
4.0 4.0 1.0 178 KB

JavaScript validation engine

Home Page: http://courtroom.github.io/courtroom/

License: MIT License

JavaScript 0.40% TypeScript 99.60%

courtroom's People

Contributors

jameskmonger avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

agentantelope

courtroom's Issues

Publish on NPM

Looks like the name courtroom is not taken yet!

https://registry.npmjs.org/courtroom

Might be worth dropping the version number down to < 1.0.0 to indicate that the package is still under heavy development and has not stabilised yet.

Allow sibling laws

It would be nice to be able to add laws to multiple properties at the same time.

If we wanted both name and display_name to both be between 4 and 24 characters long, we could be able to do a syntax like this:

c.trial(['name', 'display_name']).laws.minLength(4).maxLength(24);

Not too sure about the logistics behind how we'd do this, though.

Support regex matcher

Something like:

c.trial('email').laws.matches(/[A-Za-z_\.]+\@[A-Za-z_\.]+\.\w+/g);

Allow trialling child properties

It would be good to be able to trial child properties, such as to be able to say that the "length" of property "bla" must be between 5 and 10, it could be trialled like this:

c.trial("bla").trial("length").laws.between(5, 10);

Or potentially with a slightly different syntax:

c.trial(["bla", "length"]).laws.between(5, 10);

I think that the first syntax would be easier to use

Rename "Jury" to "Law"

This might sound a bit pedantic, but why are validation rules called Juries and not Laws? I'm no law student, but to me it doesn't make sense that a Lawbook contains a collection of Juries, when it seems more natural that it should have a collection of Laws. When I was first reading the code, I struggled a bit with the Jury concept, wondering where it fitted.

Also the documentation makes no mention of Jury. Is this something that you are looking to refactor anyway?

Use a Node test framework for unit tests

I think that testing with Karma is unnecessary at the moment, we should instead be using a Node testing framework as we don't need to run a browser testing framework.

I think Mocha would be a good fit, but I'm not sure about its compatibility with Jasmine.

AMD modules in NPM

In the last publish, the Typescript has been compiled down to AMD modules. This is not great for Node, which only supports the CommonJS module strategy. I do like the change to the directory structure, though!

Can we publish CommonJS modules to NPM?

$ tsc --module commonjs

Plain English API for assigning laws

Current syntax for assigning laws is not very readable:

c.trial('name').laws.is('Simon');
c.trial('name').laws.not('Simon');

Might be nicer to have a syntax that reads like this:

c.trial('name').should.equal('Simon');
c.trial('name').should.not.equal('Alex');

Above, we've implemented the not negation property . This could be used for negating any laws, not just equal.

Some other laws:

c.trial('name').should.have.length.above(3);
c.trial('name').should.have.length.below(20);
c.trial('age').should.be.above(18);
c.trial('email').should.not.match(/[A-Za-z_\.]+\@[A-Za-z_\.]+\.\w+/g)

Any thoughts on this @Jameskmonger?

Set up an automated development environment

Set up a grunt development environment which watches for changes, builds the projects to test-build and then runs the tests. This will help reduce the reliance on Atom for our building.

Explicitly require npm dependencies

npm WARN peerDependencies The peer dependency karma@>=0.9 included from karma-phantomjs-launcher will no
npm WARN peerDependencies longer be automatically installed to fulfill the peerDependency 
npm WARN peerDependencies in npm 3+. Your application will need to depend on it explicitly.
npm WARN peerDependencies The peer dependency phantomjs@>=1.9 included from karma-phantomjs-launcher will no
npm WARN peerDependencies longer be automatically installed to fulfill the peerDependency 
npm WARN peerDependencies in npm 3+. Your application will need to depend on it explicitly.

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.