Meteor-CollectionFS icon indicating copy to clipboard operation
Meteor-CollectionFS copied to clipboard

Is there a way for validating the metadata information ?

Open tagrudev opened this issue 10 years ago • 1 comments

Using cfs:gridfs I am looking for a way to validate the inputs in metadata is there a way to do so ? I tried to use the beforeWrite hook, but it doesn't have a way to stop the writing of the file.

tagrudev avatar Sep 08 '15 13:09 tagrudev

You could use the collection-hooks package to check your data before allowing the write. Just returning false to the hook will stop writing the data.

If Media is the name of your collection, you need to write your hook as

Media.files.before.insert((userid, media) => {
    // do your validation
    if (!valid) {
        return false;
    }
});

brent-hoover avatar Oct 28 '16 01:10 brent-hoover