Skip to content

Commit

Permalink
Deploying to gh-pages from @ 1b90241 🚀
Browse files Browse the repository at this point in the history
  • Loading branch information
gregsdennis committed Jun 8, 2024
1 parent fb0877d commit 3353de7
Show file tree
Hide file tree
Showing 15 changed files with 102 additions and 4 deletions.
Binary file modified _framework/JsonSchema.Net.dll
Binary file not shown.
Binary file modified _framework/JsonSchema.Net.dll.br
Binary file not shown.
Binary file modified _framework/JsonSchema.Net.dll.gz
Binary file not shown.
Binary file modified _framework/LearnJsonEverything.Template.dll
Binary file not shown.
Binary file modified _framework/LearnJsonEverything.Template.dll.br
Binary file not shown.
Binary file modified _framework/LearnJsonEverything.Template.dll.gz
Binary file not shown.
Binary file modified _framework/LearnJsonEverything.Template.pdb.gz
Binary file not shown.
Binary file modified _framework/LearnJsonEverything.dll
Binary file not shown.
Binary file modified _framework/LearnJsonEverything.dll.br
Binary file not shown.
Binary file modified _framework/LearnJsonEverything.dll.gz
Binary file not shown.
Binary file modified _framework/LearnJsonEverything.pdb.gz
Binary file not shown.
8 changes: 4 additions & 4 deletions _framework/blazor.boot.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"mainAssemblyName": "LearnJsonEverything",
"resources": {
"hash": "sha256-XQEBlVdk6yVtAkbCdg1EwvI2WZhJkfLiYNKG+TgmcYM=",
"hash": "sha256-TZGpgbg3hJhh5zf6OB4CasfrZd7Iv9mJXR1VTtt0Io0=",
"jsModuleNative": {
"dotnet.native.8.0.6.suuomc2hr0.js": "sha256-YU6M9+jtDVnB8/wtrgIndOstzNh778Ls8g9XnbjorSk="
},
Expand All @@ -23,9 +23,9 @@
"Humanizer.dll": "sha256-1oUwdVR9fjA+/WA1TZEaL/GO26WCzaL6WdkaLl3Pnpg=",
"Json.More.dll": "sha256-xr0aE0+HsrvtjruJdaapKt2/DGB0qSUz+xD0XmvawxM=",
"JsonPointer.Net.dll": "sha256-DzV9BEIGNC1mcOpb+JYI2gGXuDG5qg157LjFTnJ6pAE=",
"JsonSchema.Net.dll": "sha256-iCLcArFhOdHD16SQ2km8JXYsJmbv4fa37t+iopIb8+w=",
"LearnJsonEverything.dll": "sha256-Lq5CRgHpSk1hV8Ob/SG8cgXtzVVmHTKjHfF1yDc1ZuE=",
"LearnJsonEverything.Template.dll": "sha256-wVUdrrLmn7vzTG1UfmuFMFRgP7I1xk8Y1TH+gs+lePc=",
"JsonSchema.Net.dll": "sha256-fMEcBvXYh4ic/8yueXWxpfstkwPxuvnMxBURilBRSGs=",
"LearnJsonEverything.dll": "sha256-ae786toGXADOcdym3mpjsfFHDnPH8MMcD3HaKnBZ15I=",
"LearnJsonEverything.Template.dll": "sha256-EYCJ5QrMzhlkibGxWWDg1Pv9e6V4i0FTLwafqK8t2XE=",
"Markdig.dll": "sha256-34Ry04hh+o21Q3VDOJoD0lmCasZYDBsC9CvOeWz3BjI=",
"Markdig.SyntaxHighlighting.dll": "sha256-YEfO9OsS0T4kDjPXOW2pJF8qg62omn4UYMy/C2tcmC4=",
"Microsoft.AspNetCore.Authorization.dll": "sha256-IsV1p8+7qyVgHgqn8Yon3RZfqKDNjdC/kTwzUwtaAlY=",
Expand Down
Binary file modified _framework/blazor.boot.json.br
Binary file not shown.
Binary file modified _framework/blazor.boot.json.gz
Binary file not shown.
98 changes: 98 additions & 0 deletions data/lessons/schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -336,3 +336,101 @@
- instance: 6.8
format: date-time
isValid: false
- id: 26b6ebca-58e6-4814-8dea-4946d444c9a8
background: |
_JsonSchema.Net_ supports every version of JSON Schema from Draft 6 forward.
Version selection can be key to figuring out how to evaluate a schema. Generally,
the version will be determined by the meta-schema, as declared by the `$schema`
keyword. However, when `$schema` is absent, it's up to the tool and user to
decide.
To set the JSON Schema version to use, you'll need to set the `EvaluateAs` property
on the evaluation options.
This setting will have no effect if the schema _does_ have `$schema`.
Lastly, this property is init-only, so you'll need to set it when creating the
options object.
\* _This lesson works by taking advantage of the fact that JSON Schema ignores unknown
keywords. So when it evaluates a schema as Draft 6 that contains keywords from
Draft 7, the Draft 7 keywords aren't processed._
docs: 'schema/basics/#schema-options'
title: 'Options: JSON Schema Version'
instructions: |
Create and configure an evaluation options object, and set the JSON Schema version
found in the `schemaVersion` variable.
inputTemplate: ''
contextCode: |-
using System;
using System.Collections.Generic;
using System.Text.Json;
using System.Text.Json.Nodes;
using System.Text.Json.Serialization;
using Json.Schema;
using Json.More;
namespace LearnJsonEverything;
public class Lesson : ILessonRunner<EvaluationResults>
{
public EvaluationResults Run(JsonObject test)
{
var instance = test["instance"];
var specVersion = test["version"].Deserialize<SpecVersion>(
new JsonSerializerOptions
{
Converters = { new EnumStringConverter<SpecVersion>() }
}
);
JsonSchema schema = new JsonSchemaBuilder()
.Type(SchemaValueType.Array)
.Items(new JsonSchemaBuilder()
.Type(SchemaValueType.Integer)
)
.Contains(new JsonSchemaBuilder().Const(4))
// Introduced with Draft 7
.If(new JsonSchemaBuilder().MinItems(3))
.Then(new JsonSchemaBuilder()
.Items(new JsonSchemaBuilder().MultipleOf(2))
)
// Introduced with Draft 2019-09
.MinContains(2)
// Introduced with Draft 2020-12
.PrefixItems(
new JsonSchemaBuilder().Type(SchemaValueType.String),
new JsonSchemaBuilder().Type(SchemaValueType.Boolean)
);
/* USER CODE */
return schema.Evaluate(instance, options);
}
}
tests:
- instance: [{},4]
version: Draft6
isValid: false
- instance: [2,3,4,5]
version: Draft6
isValid: true
- instance: [2,3,4,5]
version: Draft7
isValid: false
- instance: [2,4,6,8]
version: Draft7
isValid: true
- instance: [2,4,6,8]
version: Draft201909
isValid: false
- instance: [2,4,6,8,4]
version: Draft201909
isValid: true
- instance: [2,4,6,8,4]
version: Draft202012
isValid: false
- instance: ["a string",true,2,4,6,8,4]
version: Draft202012
isValid: true

0 comments on commit 3353de7

Please sign in to comment.