blackmo18 / kotlin-grass

Kotlin Csv to Data Class Parser
Apache License 2.0
38 stars 8 forks source link

Ignore unknown fields #14

Closed winterhate closed 3 years ago

winterhate commented 3 years ago

There should be a switch to allow ignore unmaped fields in input data.

            "parse to primitive data type with unmapped field" {
                val expected =
                    PrimitiveTypes(0, 1, 2, 3.0f, 4.0, true, "hello")
                val contents = readTestFile("/primitive-with-unmapped-field.csv").asSequence()
                val grass = grass<PrimitiveTypes>() {
                    ignoreUnknownFields = true
                }
                val parsed = grass.harvest(contents)
                val actual = parsed.first()

                assertTrue { expected == actual }
            }

where primitive-with-unmapped-field.csv is

short,int,long,float,double,boolean,string,unmapped
0,1,2,3.0,4.0,true,hello,unmapped1
5,6,7,8.0,9.0,true,hi,unmapped2

@blackmo18 I already implemented the feature, but I am unable to push the branch for review due to insufficient permissions:

12:05:33.738: [kotlin-grass] git -c core.quotepath=false -c log.showSignature=false push --progress --porcelain origin refs/heads/enhancement/ignore-unknown-field-option:enhancement/ignore-unknown-field-option --set-upstream
remote: Permission to blackmo18/kotlin-grass.git denied to winterhate.
fatal: unable to access 'https://github.com/blackmo18/kotlin-grass.git/': The requested URL returned error: 403
blackmo18 commented 3 years ago

@winterhate, may you create a pull request from your fork and create a pull request?