This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "$schema": "https://json-schema.org/draft/2020-12/schema", | |
| "$id": "/hellish-enterprise/customer-schema-20260101.json", | |
| "title": "Customer", | |
| "description": "Validation schema for customers.", | |
| "type": "object", | |
| "required": ["userId", "email", "birthDate"], | |
| "properties": { | |
| "userId": { | |
| "type": "string", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "$schema": "https://json-schema.org/draft/2020-12/schema", | |
| "$id": "/hellish-enterprise/customer-schema-20260202.json", | |
| "title": "Customer", | |
| "description": "Validation schema for customers.", | |
| "type": "object", | |
| "required": ["userId", "email", "birthDate", "displayName"], | |
| "properties": { | |
| "userId": { | |
| "type": "string", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "$schema": "https://json-schema.org/draft/2020-12/schema", | |
| "$id": "/hellish-enterprise/customer-schema-20260303.json", | |
| "title": "Customer", | |
| "description": "Validation schema for customers.", | |
| "type": "object", | |
| "required": ["userName", "email", "birthDate", "displayName", "items"], | |
| "properties": { | |
| "userName": { | |
| "type": "string", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void Main() | |
| { | |
| var john1 = new CustomerDto20260101 | |
| { | |
| UserId = "john-1", | |
| Email = "john.fst@foomail.com", | |
| BirthDate = new DateTime(2001, 01, 01), | |
| }; | |
| var john2 = new CustomerDto20260202 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public string Serialize(Customer customer, string schemaName, JsonSchema schema) | |
| { | |
| var jsonDoc = JsonSerializer.SerializeToDocument(customer, GetSerializerOptions()); | |
| var evaluation = schema.Evaluate(jsonDoc.RootElement, GetEvaluationOptions()); | |
| var assembly = Assembly.GetAssembly(typeof(JsonSchema)); | |
| var fileVersion = | |
| assembly | |
| .GetCustomAttribute<AssemblyFileVersionAttribute>()? | |
| .Version; | |
| var validatorName = $"{assembly.GetName().Name}-{fileVersion}"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "name": "Pellegriff", | |
| "age": 1, | |
| "miceCaught": 0, | |
| "espressosSpilled": 2, | |
| "$schema": "/cat/schema-20260310.json", | |
| "$validation": { | |
| "tool": "JsonSchema.Net-9.1.3", | |
| "timestamp": "2026-03-17T07:52:34.837129Z", | |
| "result": true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let toValidatedJson (schemaText: string) (schemaName: string) (o: obj) = | |
| let jsonDoc = JsonSerializer.SerializeToDocument(o, serializerOptions) | |
| let schema = JsonSchema.FromText(schemaText) | |
| let evalOptions = EvaluationOptions() | |
| evalOptions.OutputFormat <- OutputFormat.Flag | |
| evalOptions.RequireFormatValidation <- true | |
| let results = schema.Evaluate(jsonDoc.RootElement, evalOptions) | |
| if results.IsValid then | |
| let jsonObj = JsonObject.Create(jsonDoc.RootElement) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static class Ext | |
| { | |
| public static IEnumerable<TR> SelectNotNull<T, TR>(this IEnumerable<T> source, Func<T, TR?> fn) where TR : struct | |
| { | |
| return source.Select(fn).Where(it => it != null).Cast<TR>(); | |
| } | |
| public static IEnumerable<TR> SelectNotNull<T, TR>(this IEnumerable<T> source, Func<T, TR?> fn) where TR : class | |
| { | |
| return source.Select(fn).Where(it => it != null).Cast<TR>(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| namespace FizzBuzzEnumerable; | |
| using System.Collections; | |
| using System.Collections.Generic; | |
| class Program | |
| { | |
| public class FizzBuzzEnumerable : IEnumerable<string> | |
| { | |
| public IEnumerator<string> GetEnumerator() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| open System | |
| open System.Threading.Tasks | |
| open Microsoft.AspNetCore.Builder | |
| open Microsoft.Extensions.Hosting | |
| open Microsoft.AspNetCore.Http | |
| let getHandler (ctx : HttpContext) : Task = | |
| let routePath = ctx.Request.RouteValues["path"] :?> string | |
| let nonNullPath = if routePath = null then "" else routePath | |
| ctx.Response.WriteAsync(sprintf "Hello %s" nonNullPath) |
NewerOlder