Skip to content

Instantly share code, notes, and snippets.

@bielawb
Created January 31, 2023 22:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bielawb/c5074b344012864f27c6c95b84b3fbd4 to your computer and use it in GitHub Desktop.
Save bielawb/c5074b344012864f27c6c95b84b3fbd4 to your computer and use it in GitHub Desktop.
Praca ze schematem pliku JSON - prosty obiekt
$schema = @'
{
"$schema": "http://json-schema.org/draft-07/schema",
"type": "object",
"properties": {
"foo": {
"type": "string",
"pattern": "^.{3}$"
}
},
"required": ["foo"]
}
'@
'{ "foo": "bar" }' | Test-Json -Schema $schema
# True
'{ "bar": "foo" }' | Test-Json -Schema $schema
# PropertyRequired: #/foo
# False
'{ "foo": "baaaar" }' | Test-Json -Schema $schema
# PatternMismatch: #/foo
# False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment