GithubHelp home page GithubHelp logo

travishorn / csval Goto Github PK

View Code? Open in Web Editor NEW
33.0 33.0 6.0 775 KB

Check CSV files against a set of validation rules.

License: MIT License

JavaScript 100.00%
cli csv data json-schema parser validation

csval's People

Contributors

dependabot[bot] avatar travishorn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

csval's Issues

is JSON Schema fully supported?

Your readme shows the following JSON Schema fragment

{
  "type": "object",
  "properties": {
    "salary": {
      "type": "number"
    }
  }
}

However, this is not valid JSON Schema, right?
I mean, the $schema and definitions nodes are missing as shown in this example.

Does csval really support complete JSON Schema as the specification documents?

Thanks for your help,
Mario

{
    "$schema": "http://json-schema.org/draft-06/schema#",
    "definitions": {
        "Artist": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
                "name": {
                    "type": "string"
                },
                "founded": {
                    "type": "integer"
                },
                "members": {
                    "type": "array",
                    "items": {
                        "type": "string"
                    }
                }
            },
            "required": [
                "founded",
                "members",
                "name"
            ],
            "title": "Artist"
        },

...

Delimiter support and schema issue

Hi Travis,

I've started playing around with this csval and so far I like it but I've got a few questions

  1. Are delimiters other than comma supported?
  2. I'm running into an issue specifying a second field for validation. I believe I've got a valid CSV (csval told me that when I tried it without a schema) but when I add a second field for validation, it fails for all rows. Can I get some help?

Thanks.

Strict validation (column names/order)

Is there a flag (or something that I need to specify in json schema) to get strict validation of the csv columns? What I'm looking for is

  1. The columns specified in the schema (and only those) are valid. Changes to those column headers (order or type) cause failures.

Is there a way to do that in current functionality? Would you like me to provide an example to better illustrate it?

Stream file contents?

Have you ever considered streaming the csv in on a chunk basis? I think that could help this really work for very large CSVs. I'd be very interested in this.

Something seems off here

I just built a docker image with the latest version from this repo and it's not working as expected. I had built one docker image locally (npm link) with my changes and it does respect additionalProperties. The difference I'm seeing is that for some reason the latest from npm is flagging my test csv as having missing values when the regex for the column allows for empty values. Also the column is not marked as a required field so I'm not sure of the difference.

I've verified inside the docker image that my changes are there but now it's not behaving as it should. Is something possibly messed up with the release?

required json schema rule doesn't seems to work

Hi,
I experiment some trouble by implementing the required option. It doesn't seem to work. In your example, the usage of required it's pretty confusing. You seem to look for the entire colone, not for a field in this colone.

You can require certain fields, as well. Consider this rules file.

{
"properties": {
"age": {
"type": "number"
}
},
"required": ["age"]
}
This CSV file would pass.

name,age,salary
John,30,100000
Jane,50,150000
This one would fail.

name,salary
John,100000
Jane,150000

Beside I try to implement a conditionnal required, I have tried all the combination on this post :
https://stackoverflow.com/questions/38717933/jsonschema-attribute-conditionally-required

Without any success.

Best regards

New release for non-vulnerable hoek version

hoek subject to prototype pollution via the clone function.
Dependabot cannot update @hapi/hoek to a non-vulnerable version
The latest possible version that can be installed is 6.2.4 because of the following conflicting dependencies:

[email protected] requires @hapi/[email protected] via @hapi/[email protected]
[email protected] requires @hapi/hoek@^6.0.0 via [email protected]
[email protected] requires @hapi/hoek@^8.3.0 via a transitive dependency on @hapi/[email protected]
No patched version available for @hapi/hoek
The earliest fixed version is 9.0.4.

hoek versions prior to 8.5.1, and 9.x prior to 9.0.3 are vulnerable to prototype pollution in the clone function. If an object with the proto key is passed to clone() the key is converted to a prototype. This issue has been patched in version 9.0.3, and backported to 8.5.1.

Text Files

We use txt file and csv format. Is there a way to pass in .txt files and received the same validation.

rules for co-existence of values

Thank you for this great project!

I am trying to come up with a schema i.e.:

{
  "properties" : {
    "aaa": {
      "type": "string",
      "minLength": 0
    },
    "bbb": {
      "type": "string",
      "minLength": 0
    }
  }
}

such that bbb can not be "" when aaa is not ""; or bbb must be "" when aaa is ""; so the validate() returns the error when either aaa or bbb is "", returns true when not both "" or both having values.

I am very new to programming; and I have tried to look through the JSON Schema documentations and your examples but I have not found a right direction. Would you please give me some tips? Thank you so much.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.