null icon indicating copy to clipboard operation
null copied to clipboard

IsFill method support

Open apopov-app opened this issue 7 years ago • 1 comments

This method allows you to determine whether the field was filled with marchal, which is useful for different merge models. For example: ` type MyModel struct { Name null.String Family null.String }

oldModel := LoadFromDb() // return MyModel with fields: Name: John, Family: Smith newModel := LoadFromRequest() // return MyModel with fields: Name: Alex (json: { Name: Alex })

//merge method if newModel.Name.IsFill() { oldModel.Name = newModel.Name }

if newModel.Family.IsFill() { oldModel.Family = newModel.Family }

// Result: MyModel with fields: Name: Alex, Family: Smith `

sorry for mistakes, i write with ipad

apopov-app avatar Jan 03 '19 05:01 apopov-app

I like this idea and may consider it for the next major version.

guregu avatar Apr 25 '20 10:04 guregu