Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add form-binder doc #116

Open
wants to merge 2 commits into
base: 2.4
Choose a base branch
from
Open

Add form-binder doc #116

wants to merge 2 commits into from

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