All Projects → tminglei → form-binder-java

tminglei / form-binder-java

Licence: BSD-2-Clause License
Java port of form-binder, a micro data binding and validating framework

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to form-binder-java

form-binder
A micro data binding and validating framework, very easy to use and hack
Stars: ✭ 18 (-37.93%)
Mutual labels:  data-validation, data-binding
movie-booking
An example for booking movie seat, combined of Android Data Binding, State Design Pattern and Multibinding + Autofactory. iOS version is: https://github.com/lizhiquan/MovieBooking
Stars: ✭ 80 (+175.86%)
Mutual labels:  data-binding
EBind
🔵 .NET Data Binding we deserve: concise, fast, feature-rich
Stars: ✭ 141 (+386.21%)
Mutual labels:  data-binding
android-recyclerview-binding
RecyclerView + Data Binding + LiveData Sample
Stars: ✭ 45 (+55.17%)
Mutual labels:  data-binding
GuildWars2 APIViewer
Guild Wars 2 API Viewer: An Android application used for viewing various Guild Wars 2 API endpoint responses. Developed utilizing MVVM architecture, in conjunction with Databinding, Dagger 2, Retrofit 2, and RxJava 2.
Stars: ✭ 53 (+82.76%)
Mutual labels:  data-binding
CodexMicroORM
An alternative to ORM's such as Entity Framework, offers light-weight database mapping to your existing CLR objects. Visit "Design Goals" on GitHub to see more rationale and guidance.
Stars: ✭ 32 (+10.34%)
Mutual labels:  data-binding
data-mediator
a data mediator framework bind callbacks for any property
Stars: ✭ 66 (+127.59%)
Mutual labels:  data-binding
Trailers
An open source app that is refactored to demo MVVM architecture
Stars: ✭ 20 (-31.03%)
Mutual labels:  data-binding
Villains-and-Heroes
Android app built with MVP architectural approach and uses Marvel Comics API that allows developers everywhere to access information about Marvel's vast library of comics. ⚡
Stars: ✭ 53 (+82.76%)
Mutual labels:  data-binding
Pokehub
This is a sample project that uses Graphql API's with Rx implementation.
Stars: ✭ 40 (+37.93%)
Mutual labels:  data-binding
databind-js
A powerful and flexible MVC data binding library
Stars: ✭ 16 (-44.83%)
Mutual labels:  data-binding
leaf.js
一个使用Proxy劫持的下一代状态管理方案
Stars: ✭ 12 (-58.62%)
Mutual labels:  data-binding
deepchecks
Test Suites for Validating ML Models & Data. Deepchecks is a Python package for comprehensively validating your machine learning models and data with minimal effort.
Stars: ✭ 1,595 (+5400%)
Mutual labels:  data-validation
pyvaru
Rule based data validation library for python 3.
Stars: ✭ 17 (-41.38%)
Mutual labels:  data-validation
flickr-android
A small sample app to showcase architecting app using Clean Architecture and MVVM
Stars: ✭ 25 (-13.79%)
Mutual labels:  data-binding
NestedReact
BackboneJS compatibility layer for React-MVx MVVM framework.
Stars: ✭ 79 (+172.41%)
Mutual labels:  data-binding
check-engine
Data validation library for PySpark 3.0.0
Stars: ✭ 29 (+0%)
Mutual labels:  data-validation
AndroidMVPArchitecture
Android MVP architecture sample project with or without RxJava and Dagger2 and Kotlin
Stars: ✭ 78 (+168.97%)
Mutual labels:  data-binding
Zenject-2019
Dependency Injection Framework for Unity3D
Stars: ✭ 2,567 (+8751.72%)
Mutual labels:  data-binding
RxProperty
RxJava binding APIs for observable fields and observable collections from the Data Binding Library
Stars: ✭ 17 (-41.38%)
Mutual labels:  data-binding

form-binder-java

Build Status

Form-binder-java is java port of form-binder, a micro data binding and validating framework.

Features

  • very lightweight, only ~1500 lines codes (framework + built-in extensions)
  • easy use, no verbose codes, and what you see is what you get
  • high customizable, you can extend almost every executing point
  • easily extensible, every extension interface is an alias of FunctionN
  • immutable, you can share mapping definition object safely

Usage

To use form-binder-java, pls add the dependency to your maven project file:

<dependency>
  <groupId>com.github.tminglei</groupId>
  <artifactId>form-binder-java</artifactId>
  <version>0.13.5</version>
</dependency>

Then you can use it in your codes like this:

form-binder description

  1. define your binder
  2. define your mappings
  3. prepare your data
  4. bind and consume

p.s. every points above (1)/(2)/(3)/(4)/ are all extendable and you can easily customize it.

How it works

Principle

The core of form-binder is Mapping, tree structure mappings. With depth-first algorithm, it was used to validate data and construct the result value object.

Details

form-binder description

Major Components:

[1] binder: facade, used to bind and trigger processing, two major methods: bind, validate
[2] messages: used to provide error messages
[3] mapping: holding constraints, processors, and maybe child mapping, etc. used to validate/convert data, two types of mappings: field and group
[4] data: inputting data map

Check here for framework details.

binder bind method signature (return an BindObject and let user to continue processing):

//bind mappings to data, and return an either, holding validation errors or converted value
public BindObject bind(Framework.Mapping<?> mapping, Map<String, String> data, String root)

binder validate method signature (validate only and not consume converted data):

//return (maybe processed) errors
public <Err> Optional<Err> validate(Framework.Mapping<?> mapping, Map<String, String> data, String root)

Check here for built-in mappings.

Extension Types:

(1) ErrProcessor: used to process error seq, like converting it to json
(2) PreProcessor: used to pre-process data, like omitting $ and , from $3,013
(3) Constraint: used to validate raw string data
(4) ExtraConstraint: used to valdate converted value

* Check here for built-in PreProcessor/ErrProcessor.
**Check here for built-in Constraint/ExtraConstraint.

Options/Features:

  1. label: feature, readable name for current group/field
  2. map: feature, map converted value to another type
  3. i18n: feature, label starting with @ will be used as a message key to fetch a i18n value from messages
  4. bean: feature, transform converted values to a specified java bean
  5. eagerCheck: option, check errors as more as possible; default false, return right after a validation error found
  6. skipUntouched: option, whether skip checking untouched empty field/values; default false, won't skip untouched
  7. touchedChecker: function, check whether a field was touched by user; if yes, required field can't be empty

Attachment object and meta info:

If you want to associate some extra data to a mapping, now, after some preparing, you can do it like this:

Mapping<BindObject> pet = $(mapping(
    field("id", $(vLong()).desc("pet id").$$),
    field("name", $(text(required())).desc("pet name").$$),
    field("category", $(attach(required()).to(mapping(
        field("id", vLong(required())),
        field("name", text(required()))
    ))).desc("category belonged to").$$),
    field("photoUrls", $(list(text())).desc("pet's photo urls").$$),
    field("tags", $(list(text())).desc("tags for the pet").$$),
    field("status", petStatus)
)).desc("pet info").$$;

With this and meta info, which can be fetched from a mapping / pre-processor / constraint / extra-constraint with [instance].meta(), form-binder-java allows third party tools, like binder-swagger-java, to deeply know its structure and details, just like they got through java reflections, then based on it to do more.

p.s. for more dev and usage details pls check the source codes and test cases.

Build & Test

To hack it and make your contribution, you can setup it like this:

 $ git clone https://github.com/tminglei/form-binder-java.git
 $ cd form-binder-java
 $ mvn compile
...

To run the tests, pls execute:

 $ mvn test

License

The BSD License, Minglei Tu <[email protected]>

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].