Skip to content

feat(notes): enforce max length limits on note title and content#109

Open
sricharan12-hub wants to merge 1 commit into
niharika-mente:mainfrom
sricharan12-hub:fix/note-length-limits
Open

feat(notes): enforce max length limits on note title and content#109
sricharan12-hub wants to merge 1 commit into
niharika-mente:mainfrom
sricharan12-hub:fix/note-length-limits

Conversation

@sricharan12-hub

Copy link
Copy Markdown

Overview

Adds maximum-length validation for a note's title and content on both the
backend (authoritative) and the frontend (UX). Previously neither had any upper
bound, so arbitrarily large notes could be submitted and stored.

Closes #84

Limits: title ≤ 100 characters, content ≤ 10000 characters.

Changes

Backend

  • models/Note.js — add maxlength to title (100) and content (10000) with
    clear messages, and trim: true on the title.
  • controllers/notesController.jscreateNote / updateNote reject over-length
    title/content with a friendly 400 message before saving (rather than surfacing
    a raw Mongoose validation error). Length constants mirror the model. updateNote
    already runs runValidators: true.

Frontend

  • CreatePage.jsx and NoteDetailPage.jsx — cap the title/content inputs via
    maxLength and show a live current/max character counter under each field.

Acceptance criteria

  • Over-length title/content is rejected by the backend with a clear 400 message.
  • The model enforces maxlength for both fields.
  • Frontend inputs cap length via maxLength (with a counter).
  • Existing valid notes continue to work.

Testing

  • eslint passes on both edited pages; node --check passes on the model and controller.
  • Exercised the model's validators directly (no DB) with validateSync:
    • title 101 chars → rejected; title 100 → accepted.
    • content 10001 chars → rejected; content 10000 → accepted.
    • title " hello " → trimmed to "hello".
    • error message reads: Title cannot exceed 100 characters.

Notes had no maximum-length limits on title or content, so arbitrarily
large notes could be submitted and stored.

- Model (Note.js): add maxlength (title 100, content 10000) with clear
  messages, and trim the title.
- Controllers (createNote / updateNote): reject over-length title/content
  with a friendly 400 before saving; update already runs validators.
- Frontend (CreatePage, NoteDetailPage): cap the title/content inputs via
  maxLength and show a live character counter.

Limits: title <= 100 characters, content <= 10000 characters.

Closes niharika-mente#84
@coderabbitai

coderabbitai Bot commented Jul 2, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@sricharan12-hub, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 19 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 3a052c0b-0c6a-43df-9b74-39f0bc15204b

📥 Commits

Reviewing files that changed from the base of the PR and between 87148ba and 6e4ab7c.

📒 Files selected for processing (4)
  • backend/src/controllers/notesController.js
  • backend/src/models/Note.js
  • frontend/src/pages/CreatePage.jsx
  • frontend/src/pages/NoteDetailPage.jsx
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add length limits / validation for note title and content

1 participant