Skip to content

Complex Data Format Linters? Test-Json, Test-yaml, Test-xml, Test-CSV #3613

Closed

Description

@DarwinJS

Sure would be nice to be able to do basic validation of the syntax fussy data formats in code - and even in the console not having to use an editor or website.

I do not mean to imply that powershell do broadbased syntax checking of other things - just these very common data formats that are syntax heavy and that we have to work with a lot.

Activity

  1. iSazonov commented on Apr 21, 2017

    @iSazonov
    Collaborator

    I believe Test-CSV is impossible - what is formal rules?
    Test-Json and Test-xml can be implemented - we have all for that.
    Test-yaml only once we receive support for YAML in PowerShell.

  2. added
    WG-Cmdlets
    Issue-Discussion
    on Apr 21, 2017
  3. BrucePay commented on Apr 24, 2017

    @BrucePay
    Collaborator

    Darwin (@DarwinJS) what form do you see this talking? The various import and convert commands already validate that documents are well-formed. Are you talking about schema validation? Better errors?

  4. DarwinJS commented on Apr 24, 2017

    @DarwinJS
    ContributorAuthor

    Ilya (@iSazonov) - I know that csv does not have a published standard, but tools like CSVEdit (http://csved.sjfrancke.nl/) have been successful at collecting all the "common formats in the wild". However, I'm not really hung on that one - it's these others that I have to deal with much more often.

    Bruce Payette (@BrucePay) - I am thinking "dedicated test- CMDLets" (if "test-" is the right verb to use for well-formed validations) to expose this functionality so that:

    • I can easily discover this functionality.
    • I can be sure to only receive errors of the format validation (execution of the general CMDLets could be emitting errors for many conditions and I don't know how many different validation errors it might be capable of emitting). Especially important when I as the script author am not the author of the formatted input data.
    • I can be given the exact position in the data where the error occurs - like I am used to in online linters - this may already be part of the built-in check, but if it is not for any given command, that test-whatever would be diligent in surfacing that information.
    • If the existing functionality does not do it already, perhaps reporting all errors that can be found, not simply stopping on the first one found.

    Although I think a CMDLet is more discoverable, if providing a CMDLet is difficult, perhaps "Convert-ToYaml -validateonly" that just gives a true or the location of the first error.

    I haven't wrapped my head around this enough to know if validation errors are all that the "Convert-" CMDLets output? But even if so, I would still say that having dedicated cmdlets would help people understand that better and through broader use feedback might improve the quality of the validation code.

    In general it seems like there could be a lot more "Test-" CMDLets across all of powershell.

  5. iSazonov commented on Oct 31, 2018

    @iSazonov
    Collaborator

    Test-Json was added.

  6. microsoft-github-policy-service commented on Nov 16, 2023

    @microsoft-github-policy-service
    Contributor

    This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.

  7. microsoft-github-policy-service commented on Nov 16, 2023

    @microsoft-github-policy-service
    Contributor

    This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.

  8. added
    Resolution-No Activity
    on Nov 16, 2023
  9. microsoft-github-policy-service commented on Nov 16, 2023

    @microsoft-github-policy-service
    Contributor

    This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.

  10. microsoft-github-policy-service commented on Nov 23, 2023

    @microsoft-github-policy-service
    Contributor

    This issue has been marked as "No Activity" as there has been no activity for 6 months. It has been closed for housekeeping purposes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-DiscussionResolution-No ActivityWG-Cmdlets

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions