INNER CODE UNIT · JavaScript

isValidUrl

plexinc/papr · benchmark/mongoose.js:6

function isValidUrl(value) {
  try {
    // native url package will throw a TypeError on invalid urls

    new URL(value);
    return true;
  } catch {
    return false;
  }
}

const sampleSchema = new mongoose.Schema(
  {
    age: Number,
    binary: Buffer,
    city: String,
    firstName: {
      required: true,

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…