uuid#validate JavaScript Examples

The following examples show how to use uuid#validate. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: [slug].json.js    From lnft with GNU Affero General Public License v3.0 6 votes vote down vote up
export async function get({ request: { headers }, locals, params }) {
  try {
    let { slug } = params;
    let { q } = locals;

    let artwork;
    if (validate(slug)) {
      ({ artworks_by_pk: artwork } = await q(getArtwork, { id: slug }));
    } else {
      let { artworks } = await q(getArtworkBySlug, { slug, limit: 10 });
      artwork = artworks[0];
    }

    if (!artwork) return { status: 500 };

    let { artworks: others } = await q(getArtworksByArtist, {
      id: artwork.artist_id,
    });

    others = others.filter((a) => a.id !== artwork.id).slice(0, 3);

    return {
      body: {
        artwork,
        others,
      },
      headers,
    };
  } catch (e) {
    console.log(e);
    return {};
  }
}
Example #2
Source File: validateUUID.js    From logchimp with Apache License 2.0 5 votes vote down vote up
validateUUID = (id) => validate(id)
Example #3
Source File: crypto.js    From umami with MIT License 5 votes vote down vote up
export function isValidUuid(s) {
  return validate(s);
}