Skip to content

Commit

Permalink
(validators): added demo html validators
Browse files Browse the repository at this point in the history
  • Loading branch information
Egor Didenko committed Jun 7, 2024
1 parent e4c3d22 commit 13023dc
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions demo/validators.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<!DOCTYPE html>
<base href="../../" />

<head>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" href="./solutions/file-uploader/regular/index.css">
<script async=""
src="https://cdn.skypack.dev/-/[email protected]/dist=es2020,mode=raw,min/dist/es-module-shims.js"></script>
<script type="importmap">
{
"imports": {
"@symbiotejs/symbiote": "./node_modules/@symbiotejs/symbiote/build/symbiote.js",
"@uploadcare/upload-client": "./node_modules/@uploadcare/upload-client/dist/esm/index.browser.mjs",
"@uploadcare/image-shrink": "./node_modules/@uploadcare/image-shrink/dist/esm/index.browser.mjs"
}
}
</script>
<script type="module">
import * as LR from './index.js';

LR.registerBlocks(LR);
</script>
</head>

<lr-file-uploader-regular ctx-name="my-uploader"></lr-file-uploader-regular>
<lr-config multipleMax="2" ctx-name="my-uploader" pubkey="demopublickey"></lr-config>
<lr-upload-ctx-provider ctx-name="my-uploader"></lr-upload-ctx-provider>

<script type="module">
const config = document.querySelector("lr-config")

const imagesOnly = (fileInfo, block) => {
if (!fileInfo.isImage) {
return {
message: "This isn't image",
payload: {
entry: fileInfo
}
}
}
}

config.fileValidators = [imagesOnly]

config.collectionValidators = []
</script>

0 comments on commit 13023dc

Please sign in to comment.