question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeError: validate_1.Schema is not a constructor

See original GitHub issue

I keep getting TypeError: validate_1.Schema is not a constructor. My code is below.

import Schema from 'validate';

import { IUser } from '../common/interfaces';

const userSchema = new Schema({
  userName: {
    type: String,
    required: true,
    length: { min: 3 },
    message: {
      type: 'The user name must be a string.',
      required: 'A user name must be provided.',
      length: 'A user name must be at least 3 characters.'
    }
  }
});

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:7

github_iconTop GitHub Comments

2reactions
jstevenson81commented, Nov 5, 2019

Did the same as you import schema from ‘validate’

Same problem: FAIL tests/Validator.spec.ts ● Test suite failed to run

TypeError: validate_1.default is not a constructor
import Schema from 'validate';

const userSchema = new Schema({
  userName: {
    type: String,
    required: true,
    length: { min: 3, max: 255 },

    message: {
      type: 'The user name must be a string',
      required: 'User name is required to create/update/add to a user account.'
    }
  }
});
1reaction
raman-nbgcommented, Mar 25, 2020

Thank you @DragonRaider5 for fixing this. Are there any plans to merge the change and release a new version?

Read more comments on GitHub >

github_iconTop Results From Across the Web

mongoose TypeError: Schema is not a constructor
I have encountered the same thing. I have previous code like this var mongoose = require('mongoose'); var Schema = mongoose.Schema(); var schema =...
Read more >
TypeError: Schema is not a constructor (Example) - Treehouse
Hi all. I wonder if someone can help me, please. :) Here's my code:
Read more >
Mongoose model TypeError: Schema is not a constructor ...
[Solved]-Mongoose model TypeError: Schema is not a constructor-node.js ... The error is because your const mongoose has the instance of mongoose.connect and not ......
Read more >
schemastery - npm
Lightweight. Much smaller than other validation libraries. Easy to use. You can use any schema as a function or constructor directly. Powerful. Schemastery ......
Read more >
Mongoose v6.8.2: Validation
model('Cat', schema); // This cat has no name :( const cat = new Cat(); let error; try { await cat.save ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found