Skip to content
forked from bright/patchy

A Spring method argument resolver that is suitable for PATCH handling combined with validation

License

Notifications You must be signed in to change notification settings

impatient/patchy-1

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

patchy

A Spring method argument resolver that is suitable for PATCH handling combined with validation.

This simple library let's you apply client provided changes to an entity while at the same time keep the benefits of request validation:

class Request : PatchyRequest {
    @get:NotBlank
    val firstName:String? by { _changes }

    @get:NotBlank
    val lastName:String? by { _changes }
    
    override var _changes = mapOf<String,Any?>()
}

@RestController
class PatchingCtrl {
    @RequestMapping("/", method = arrayOf(RequestMethod.PATCH))
    fun update(@Valid request: Request){
        request.applyChangesTo(entity)
    }
}

Setup

build.gradle:

repositories {
    jcenter()
    maven { url "https://jitpack.io" }
}

dependencies {
    compile 'com.github.bright:patchy:v0.1.0'
    ...
}

Then import the configuration with:

@SpringBootApplication
@EnableWebMvc
@Import(PatchyConfiguration::class)
open class Application {

About

A Spring method argument resolver that is suitable for PATCH handling combined with validation

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Kotlin 100.0%