Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consolidate use of input box validation #3049

Merged
merged 3 commits into from
Jan 4, 2023
Merged

Conversation

mattseddon
Copy link
Member

@mattseddon mattseddon commented Jan 4, 2023

2/2 main <- #3048 <- this

This PR consolidates our use of validation functions with respect to the VS Code InputBox.

Demo

Screen.Recording.2023-01-04.at.4.21.38.pm.mov

@mattseddon mattseddon self-assigned this Jan 4, 2023
@mattseddon mattseddon changed the base branch from main to queue-quick-pick January 4, 2023 05:23
@mattseddon mattseddon marked this pull request as ready for review January 4, 2023 05:31
window.showInputBox({
title,
value
})

export const getValidInput = (
const getValidInput = (
Copy link
Member Author

Choose a reason for hiding this comment

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

[F] If we are concerned then I can try to find ~1 day to get these validators under test.

if (!includeZero) {
return number > 0
}
return number >= 0
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure if it looks better but you could turn these four lines into one:

return includeZero ? number >= 0 : number > 0

window.showInputBox({
prompt: options?.prompt,
title,
validateInput,
value: options?.value
})

const isValid = (
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this function be isValidNumber since the function is focused on checking numbers?

Base automatically changed from queue-quick-pick to main January 4, 2023 22:38
@mattseddon mattseddon force-pushed the use-integer-validator branch from 44e4f26 to cdd6a02 Compare January 4, 2023 22:39
@mattseddon mattseddon enabled auto-merge (squash) January 4, 2023 22:43
@codeclimate
Copy link

codeclimate bot commented Jan 4, 2023

Code Climate has analyzed commit c5f405a and detected 0 issues on this pull request.

The test coverage on the diff in this pull request is 45.0% (85% is the threshold).

This pull request will bring the total coverage in the repository to 96.4% (0.0% change).

View more on Code Climate.

@mattseddon mattseddon merged commit b6c4950 into main Jan 4, 2023
@mattseddon mattseddon deleted the use-integer-validator branch January 4, 2023 23:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants