0.7.0 • Published 10 years ago

chained v0.7.0

Weekly downloads
3
License
-
Repository
github
Last release
10 years ago

Chained Browser Demo

This demo shows a form validation DSL implemented with Chained in Coffeescript:

form '#form', ( check ) ->

    field '#fname', (f) -> 
        check(f.value).isNotNull().isLengthAtLeast(of: 2).show(f)

    field '#lname', (f) -> 
        check(f.value).isNotNull().isLengthAtLeast(of: 2).show(f)

    field '#uname', (f) -> check(f.value).isNotNull().userNameShouldNotExist(msg: 'User already exists').show(f)

    field '#password1', (f) ->
        check(f.value).isNotNull().isLengthAtLeast(of: 4).show(f)

    field '#password2', (f) ->
        check(f.value).isNotNull().shouldMatchElement(element: '#password1', msg: "passwords should match").show(f)
  • form and field functions setup focusout callbacks with chained, deferred objects. check is an alias for chained._.

  • The method show renders popup error messages whenever one of the promise associated with a predicate-chain fails.

  • The method userNameShouldNotExist is based on an Ajax get and, as such, is promise based. Chained allows to use the result in the next predicate as if it were synchronous. The users file at the moment contains only the user zack.

0.7.0

10 years ago

0.6.0

10 years ago

0.5.4

11 years ago

0.5.3

11 years ago

0.5.2

11 years ago

0.5.1

11 years ago