{"id":37028753,"url":"https://github.com/gitbucket/scalatra-forms","last_synced_at":"2026-01-14T03:26:39.328Z","repository":{"id":8217996,"uuid":"9654921","full_name":"gitbucket/scalatra-forms","owner":"gitbucket","description":"A library to validate and map request parameters for Scalatra.","archived":true,"fork":false,"pushed_at":"2017-11-16T05:40:00.000Z","size":2007,"stargazers_count":30,"open_issues_count":0,"forks_count":4,"subscribers_count":12,"default_branch":"master","last_synced_at":"2024-03-26T05:43:28.569Z","etag":null,"topics":["ajax","scala","scalatra","validation"],"latest_commit_sha":null,"homepage":null,"language":"Scala","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gitbucket.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-04-24T18:34:20.000Z","updated_at":"2023-11-07T12:36:06.000Z","dependencies_parsed_at":"2022-08-06T22:15:20.543Z","dependency_job_id":null,"html_url":"https://github.com/gitbucket/scalatra-forms","commit_stats":null,"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"purl":"pkg:github/gitbucket/scalatra-forms","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gitbucket%2Fscalatra-forms","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gitbucket%2Fscalatra-forms/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gitbucket%2Fscalatra-forms/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gitbucket%2Fscalatra-forms/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gitbucket","download_url":"https://codeload.github.com/gitbucket/scalatra-forms/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gitbucket%2Fscalatra-forms/sbom","scorecard":{"id":427981,"data":{"date":"2025-08-11","repo":{"name":"github.com/gitbucket/scalatra-forms","commit":"fe0e04058a69cb51410117b81688fc33c29c62bb"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Code-Review","score":0,"reason":"Found 1/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Maintained","score":0,"reason":"project is archived","details":["Warn: Repository is archived."],"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"License","score":0,"reason":"license file not detected","details":["Warn: project does not have a license file"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 2 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-19T02:40:09.071Z","repository_id":8217996,"created_at":"2025-08-19T02:40:09.071Z","updated_at":"2025-08-19T02:40:09.071Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28408843,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T01:52:23.358Z","status":"online","status_checked_at":"2026-01-14T02:00:06.678Z","response_time":107,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ajax","scala","scalatra","validation"],"created_at":"2026-01-14T03:26:38.673Z","updated_at":"2026-01-14T03:26:39.314Z","avatar_url":"https://github.com/gitbucket.png","language":"Scala","readme":"scalatra-forms\n==============\n\nA library to validate and map request parameters for Scalatra.\n\n**Notice:** This project is maintained no longer because it has been merged into Scalatra! See [the Scalatra documentation](http://scalatra.org/guides/2.6/formats/forms.html) to know details.\n\nGetting Started\n--------\n\nAt first, add the following dependency into your build.sbt to use scalatra-forms.\n\n```scala\nlibraryDependencies += \"io.github.gitbucket\" %% \"scalatra-forms\" % \"1.1.0\"\n```\n\nNext, add ```ValidationJavaScriptProvider``` to Bootstrap of your Scalatra application.\n\n```scala\nimport io.github.gitbucket.scalatra.forms._\n\nclass ScalatraBootstrap extends LifeCycle {\n  override def init(context: ServletContext) {\n    ...\n    context.mount(new ValidationJavaScriptProvider, \"/assets/js/*\")\n    ...\n  }\n}\n```\n\nscalatra-forms is now ready.\n\nDefine a form mapping. It's a similar to Play2, but scalatra-forms is more flexible.\n\n```scala\nimport io.github.gitbucket.scalatra.forms._\n \ncase class RegisterForm(name: String, description: String)\n\nval form = mapping(\n  \"name\"        -\u003e text(required, maxlength(40)), \n  \"description\" -\u003e text()\n)(RegisterForm.apply)\n```\n\nNext, create a servlet (or filter) which extends ScalatraServlet (or ScalatraFilter).\nIt also mixed in ```FormSupport``` or ```ClientSideValidationFormSupport```.\nThe object which is mapped request parameters is passed as an argument of action.\n\n```scala\nclass RegisterServlet extends ScalatraServlet with ClientSideValidationFormSupport {\n  post(\"/register\", form) { form: RegisterForm =\u003e\n    ...\n  }\n}\n```\n\nIn the HTML, you have to do two things below.\n\n- Add ```\u003cscript\u003e``` to import jQuery which is required by validation.js\n- Add ```\u003cscript\u003e``` to import validation.js which helps client side validation provided by ```ValidationJavaScriptProvider```\n- Add ```validation=\"true\"``` to your ```\u003cform\u003e```\n\nscalatra-forms registers a submit event listener to validate form contents.\nThis listener posts all the form contents to ```FORM_ACTION/validate```.\nThis action is registered by scalatra-forms automatically to validate form contents.\nIt returns validation results as JSON.\n\nIn the client side, scalatra-forms puts error messages into ```span#error-FIELD_NAME```.\n\n```scala\n\u003cscript src=\"http://code.jquery.com/jquery-2.0.3.min.js\"\u003e\u003c/script\u003e\n\u003cscript src=\"/assets/js/validation.js\"\u003e\u003c/script\u003e\n...\n\u003cform method=\"POST\" action=\"/register\" validation=\"true\"\u003e\n  Name: \u003cinput type=\"name\" type=\"text\"\u003e\n  \u003cspan class=\"error\" id=\"error-name\"\u003e\u003c/span\u003e\n  \u003cbr/\u003e\n  Description: \u003cinput type=\"description\" type=\"text\"\u003e\n  \u003cspan class=\"error\" id=\"error-description\"\u003e\u003c/span\u003e\n  \u003cbr/\u003e\n  \u003cinput type=\"submit\" value=\"Register\"/\u003e\n\u003c/form\u003e\n```\n\nCustom Validation\n--------\n\nYou can create custom ```Constraint```.\n\n```scala\ndef identifier: Constraint = new Constraint(){\n  override def validate(name: String, value: String): Option[String] =\n    if(!value.matches(\"^[a-zA-Z0-9\\\\-_]+$\")){\n      Some(s\"${name} contains invalid character.\")\n    } else {\n      None\n    }\n}\n\nval form = mapping(\n  \"name\"        -\u003e text(required, identifier), \n  \"description\" -\u003e text()\n)(RegisterForm.apply)\n```\n\nYou can also create multi field validator by overriding ```validate(String, String, Map[String, String])```.\nIt's possible to look up other field value via ```params```.\n\nOther way to create multi field validator is calling ```verifying``` for mapping.\nYou can give the function yo validate the mapped case class. This function takes the mapped value and returns \n```Seq[(String, String)]``` which contains errors or ```Nil```.\n\n```scala\nval form = mapping(\n  \"reason\"      -\u003e number(required), \n  \"description\" -\u003e optional(text)\n)(ReasonForm.apply).verifying { value =\u003e\n  if(value.reason == 4 \u0026\u0026 value.descripsion){\n    Seq(\"description\" -\u003e \"If reason is 'Other' then description is required.\")\n  } else {\n    Nil\n  }\n}\n```\n\nAjax\n--------\n\nFor the Ajax action, use ```ajaxGet``` or ```ajaxPost``` instead of ```get``` or ```post```.\nActions which defined by ```ajaxGet``` or ```ajaxPost``` return validation result as JSON response.\n\n```scala\nclass RegisterServlet extends ScalatraServlet with ClientSideValidationFormSupport {\n  ajaxPost(\"/register\", form) { form: RegisterForm =\u003e\n    ...\n  }\n}\n```\n\nIn the client side, you can render error messages using ```displayErrors()```. \n\n```js\n$('#register').click(function(e){\n  $.ajax($(this).attr('action'), {\n    type: 'POST',\n    data: {\n      name       : $('#name').val(),\n      description: $('#description').val()\n    }\n  })\n  .done(function(data){\n    $('#result').text('Registered!');\n  })\n  .fail(function(data, status){\n    displayErrors($.parseJSON(data.responseText));\n  });\n});\n```\n\nRelease Notes\n--------\n### 1.1.0 - 25 Nov 2016\n\n* Scalatra 2.5.0 and Scala 2.12 support\n\n### 1.0.0 - 31 Dec 2015\n\n* Move to GitBucket organization.\n* Change group id and package name to `io.github.gitbucket`.\n* Add `put()`, `delete()`, `ajaxPut()` and `ajaxDelete()` to `ClientSidevalidationFormSupport`.\n\n### 0.2.0 - 18 Nov 2015\n\n* Fix performance issue\n\n### 0.1.0 - 9 Jul 2014\n\n* Support Scala 2.11 and Scalatra 2.3\n\n### 0.0.14 - 19 Feb 2014\n\n* Bug fix about form state after after validation succeeded.\n\n### 0.0.13 - 2 Feb 2014\n\n* Bug fix for `long` value type.\n\n### 0.0.12 - 29 Dec 2013\n\n* Formatting (such as `%s`) is available in custom messages as same as default messages.\n\n### 0.0.11 - 12 Dec 2013\n\n* Fix `dummy()` bug.\n\n### 0.0.10 - 10 Dec 2013\n\n* Add ```long``` value type.\n* Fix ```list``` bug for un-nested properties.\n\n### 0.0.9 - 6 Dec 2013\n\n* Add `dummy` value type.\n\n### 0.0.8 - 14 Nov 2013\n\n* Fix nested property handling problem.\n* Fix `verifying()` for `MappingValueType` and remove `MappingConstraint` instead of it.\n* Add `length` constraint.\n\n### 0.0.7 - 12 Nov 2013\n\n* Add `MappingConstraint` to validate converted object by `MappingValueType`.\n\n### 0.0.6 - 8 Nov 2013\n\n* Add `list()` mapping for `SingleValueType`.\n* ```ValidationJavaScriptProvider``` adds Content-Type header for validation.js.\n* Fix to run parent validations before number checking.\n\n### 0.0.5 - 3 Nov 2013\n\n* Add `oneOf()` constraint which checks whether the value is one of specified strings.\n* Fix to retrieve error message for `number()` and `double()` from ResourceBundle.\n\n### 0.0.4 - 2 Nov 2013\n\n* Add `double()` and `date()` mapping.\n* Add I18N support for error messages.\n\n### 0.0.3 - 18 Oct 2013\n\n* Add `ValidationJavaScriptProvoider`.\n* Add `list()` mapping for List property.\n\n### 0.0.2 - 10 Aug 2013\n\n* Improved nested property support.\n* Add `validate(String, String, Map[String, String])` to `Constraint`. \n  It makes possible to access other parameter in single field validation.\n* Add `verify()` to `MappingValueType` which validates the mapped instance.\n\n### 0.0.1 - 04 Aug 2013\n\n* This is the first public release.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgitbucket%2Fscalatra-forms","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgitbucket%2Fscalatra-forms","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgitbucket%2Fscalatra-forms/lists"}