Skip to content

Instantly share code, notes, and snippets.

@jdanyow
Created November 14, 2021 04:08
Show Gist options
  • Save jdanyow/a4f6c9b5854d10bcfe9c39f7345bcd10 to your computer and use it in GitHub Desktop.
Save jdanyow/a4f6c9b5854d10bcfe9c39f7345bcd10 to your computer and use it in GitHub Desktop.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>GistRun</title>
<script type="module">
import { Validator } from 'https://cdn.jsdelivr.net/npm/@cfworker/json-schema@1.9.0/dist/index.js';
const validator = new Validator({ type: 'number' });
let result = validator.validate(1);
document.body.insertAdjacentHTML('beforeend', `<pre><code>${JSON.stringify(result, null, 2)}</code></pre>`);
result = validator.validate('hello');
document.body.insertAdjacentHTML('beforeend', `<pre><code>${JSON.stringify(result, null, 2)}</code></pre>`);
</script>
</head>
<body>
<h1>Hello world!</h1>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment