MCPcopy Create free account
hub / github.com/react-dropzone/react-dropzone / allFilesAccepted

Function allFilesAccepted

src/utils/index.js:130–152  ·  view source on GitHub ↗
({
  files,
  accept,
  minSize,
  maxSize,
  multiple,
  maxFiles,
  validator,
})

Source from the content-addressed store, hash-verified

128 * @returns
129 */
130export function allFilesAccepted({
131 files,
132 accept,
133 minSize,
134 maxSize,
135 multiple,
136 maxFiles,
137 validator,
138}) {
139 if (
140 (!multiple && files.length > 1) ||
141 (multiple && maxFiles >= 1 && files.length > maxFiles)
142 ) {
143 return false;
144 }
145
146 return files.every((file) => {
147 const [accepted] = fileAccepted(file, accept);
148 const [sizeMatch] = fileMatchSize(file, minSize, maxSize);
149 const customErrors = validator ? validator(file) : null;
150 return accepted && sizeMatch && !customErrors;
151 });
152}
153
154// React's synthetic events has event.isPropagationStopped,
155// but to remain compatibility with other libs (Preact) fall back

Callers 1

useDropzoneFunction · 0.90

Calls 3

fileAcceptedFunction · 0.85
fileMatchSizeFunction · 0.85
validatorFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…