Skip to content

feat: add range error validation for datatypes#1594

Merged
MichaelSun90 merged 7 commits into
masterfrom
michael-DatatypeRangeCheck
Jan 31, 2024
Merged

feat: add range error validation for datatypes#1594
MichaelSun90 merged 7 commits into
masterfrom
michael-DatatypeRangeCheck

Conversation

@MichaelSun90

@MichaelSun90 MichaelSun90 commented Dec 4, 2023

Copy link
Copy Markdown
Contributor

Add range error check for datatypes:

  • date
  • datetime
  • datetime2
  • smalldatetime
  • datetimeoffset
  • money

Adds validate tests for datatypes:

  • Int
  • SmallInt
  • TinyInt

Referenced the changes from this PR: #1271 : fix: out-of-range date error handle
Referenced the changes from PR #815 for money validation

@codecov

codecov Bot commented Dec 4, 2023

Copy link
Copy Markdown

Codecov Report

Attention: 20 lines in your changes are missing coverage. Please review.

Comparison is base (6a961b5) 78.24% compared to head (8598f04) 66.05%.

Files Patch % Lines
src/data-types/date.ts 42.85% 2 Missing and 2 partials ⚠️
src/data-types/datetime.ts 42.85% 2 Missing and 2 partials ⚠️
src/data-types/datetime2.ts 42.85% 2 Missing and 2 partials ⚠️
src/data-types/datetimeoffset.ts 42.85% 2 Missing and 2 partials ⚠️
src/data-types/smalldatetime.ts 42.85% 2 Missing and 2 partials ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           master    #1594       +/-   ##
===========================================
- Coverage   78.24%   66.05%   -12.19%     
===========================================
  Files          93       93               
  Lines        4821     4858       +37     
  Branches      921      932       +11     
===========================================
- Hits         3772     3209      -563     
- Misses        750     1245      +495     
- Partials      299      404      +105     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Comment thread src/data-types/date.ts
}

if (value < MIN_DATE || value > MAX_DATE) {
throw new TypeError('Out of range.');

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be RangeError instead? 🤔

Comment thread src/data-types/date.ts Outdated
import { ChronoUnit, LocalDate } from '@js-joda/core';
import { type InternalConnectionOptions } from '../connection';

import { Collation } from '../collation';

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this work? 🤔

Suggested change
import { Collation } from '../collation';
import { type Collation } from '../collation';

@MichaelSun90
MichaelSun90 merged commit 19cb073 into master Jan 31, 2024
@mShan0
mShan0 deleted the michael-DatatypeRangeCheck branch January 31, 2024 21:51
@github-actions

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 16.7.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

KAMAELUA pushed a commit to KAMAELUA/tedious-decimal that referenced this pull request Apr 29, 2024
* chore: add range error validation for date types

* add validation tests for numbers

* remove only

* add money validation

* chore: remove un-needed types

---------

Co-authored-by: mShan0 <96149598+mShan0@users.noreply.github.com>
(cherry picked from commit 19cb073)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants