Skip to content

Conversation

@tminglei
Copy link

Hi,

Can I add form-binder's integration and usage doc into the guide?

Form-binder is a micro data binding and validating framework, very easy to use and hack.

With it, we can do data binding and validating very nice like this:

import com.github.tminglei.bind.simple._

class SampleServlet extends ScalatraServlet with MyFormBindSupport {

  get("/:id") {
    val mappings = tmapping(
      "id" -> long(),
      "body" -> (expendJson() >-: tmapping(
        "email" -> text(required(), email()),
        "price" -> (omitLeft("$") >-: float()),
        "count" -> number().verifying(min(3), max(10))
      ))
    )
    binder.bind(mappings, data(multiParams)).fold(
      errors => holt(400, errors),
      { case (id, (email, price, count)) =>
        // do something here
      }
    )
  }

...

Pls review and give your suggestion.

Thanks,
Minglei Tu

p.s. I didn't run and check on my local, since rubygems.org was blocked in China, and I failed to install bundler and other related dependencies. So pls help run and check it. So sorry!

@tminglei tminglei changed the title Add form-binder guide Add form-binder doc Feb 29, 2016
@rossabaker
Copy link
Member

Wow, sorry, I missed the notification on this.

I'm open to this. It looks like an alternative to scalatra-commands, if I'm understanding it right?

@tminglei
Copy link
Author

tminglei commented Apr 14, 2016

Yeah, an alternative to scalatra-commands. I developed it initially for my scalatra project.
Maybe also useful for other people. ^^

Can you help review and merge? Any suggestions pls let me know.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants