UNPKG

filepond

Version:

FilePond, where files go to stretch their bits.

41 lines (40 loc) • 1.19 kB
/*! * FilePond v5.0.2 * Copyright (c) 2017-2026 Pqina B.V. * Released under the MIT License * https://filepond.com */ import { createValidatorExtension as l } from "./common/createValidatorExtension.js"; import { isFileEntry as r, isFile as s, isFunction as c, isBlobOrFile as d } from "../utils/test.js"; import { getFilenameWithoutExtension as m } from "../utils/file.js"; import { warn as f } from "../common/console.js"; const M = l({ name: "FileNameValidator", props: {}, factory: ({ props: e }) => { const { test: a } = e; return a || f("FileNameValidator: 'test' is a required property"), { validateEntry: (t) => { const { test: i } = e; if (!r(t)) return null; const { name: n } = s(t.file) ? t.file : t; if (n === void 0) return { code: "VALIDATION_FILE_NAME_MISSING" }; const o = m(n); return i(o) ? null : { code: "VALIDATION_FILE_NAME_MISMATCH" }; }, canValidateEntry: (t) => { const { test: i } = e; return !c(i) || !r(t) ? !1 : !!(d(t.file) && t.file?.name); } }; } }); export { M as FileNameValidator };