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.

What I'm doing wrong? it's about validate body

See original GitHub issue

Hi! I need help, please.

I have a basic schema in which the name is required and I expect it returns an error message or HTTP bat request when the name is empty but not it just creates the record with the name empty.

the controller was created with the foal g rest-api entity command

const companySchema = {
  properties: {
    name: { type: 'string' },
  },
  required: ['name'],
  additionalProperties: false,
  type: 'object',
};

  @Post('/companies')
  @ValidateBody(companySchema)
  async create(ctx: Context) {
    const company = await getRepository(Company).save(ctx.request.body);
    return new HttpResponseCreated(company);
  }

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
JuanVqzcommented, Dec 3, 2020

Ups! my bad, I didn’t know. I tried in postman and it works 😇

you can close this, thanks!

0reactions
LoicPoullaincommented, Dec 3, 2020

Maybe Foal could have a way to execute hooks as well in the future.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Seeking Validation from the Wrong People Is Self-Destructive
People who have been abused, mistreated, hurt, or wronged in any other way almost universally seek validation.
Read more >
Kip Moore - The Journey To Slowheart - YouTube
JOURNEY TO SLOWHEART includes several songs that appears on Kip Moore recent album SLOWHEART, available now: ...
Read more >
Validation: The Most Powerful Relationship Skill You Were ...
1) they have lost trust and respect for each other and therefore don't show much empathy to each other, 2) they don't take...
Read more >
What is Invalidation? 5 Things You Shouldn't Say
Validation doesn't necessarily mean we agree with another's subjective reality. Validation simply allows another person's emotional state a space to exist.
Read more >
Emotional Invalidation: A Form of Emotional Abuse
Emotional invalidation is painful. Sometimes it's unintentional, but it's a sign of emotional abuse when done repeatedly and intentionally.
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