Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add schema for validation #9

Open
danlooo opened this issue May 23, 2023 · 1 comment
Open

Add schema for validation #9

danlooo opened this issue May 23, 2023 · 1 comment

Comments

@danlooo
Copy link
Owner

danlooo commented May 23, 2023

Mandarory fields:

  • users
  • expiration_date
  • group_leader

Optional fileds:

  • labels
  • every other filed

schema.yml:

# JSON Schema for metayaml files

schema: https://json-schema.org/draft/2020-12/schema
id: bgc-jena.mpg.de/metayaml/schema
title: Metayaml schema
description: Attributes of files and directories stored in YAML sidecar files
type: object
properties:
  description:
    type: string
  responsible:
    type: string
  users:
    type: array
    items:
      type: string
  expires:
    anyOf:
      - type: string
        pattern: "^([0-9]+-?)+$"
      - type: number
  labels:
    type: array
    items:
      type: string
required:
  - description
  - responsible
  - expires

good.yml:

description: test
responsible: fgans
expires: 2024-07
users:
  - dloos
  - fgans
labels:
  - project_1
  - high_res
  - esa
foo: 1
bar: baz

bad.yml:

description: test
foo: 1
@danlooo danlooo closed this as completed May 25, 2023
@danlooo danlooo reopened this May 25, 2023
@danlooo
Copy link
Owner Author

danlooo commented May 25, 2023

❯ metayaml validate good.yml schema.yml
Validation sucessfull
❯ metayaml validate bad.yml schema.yml
jsonschema.exceptions.ValidationError: 'responsible' is a required property

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant