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

feat(contains): Added possibility to check that string contains seed multiple times #1836

Merged
merged 2 commits into from
Oct 31, 2021

Conversation

Marcholio
Copy link
Contributor

contains now checks if the string contains the seed n number of times, eg. foobarfoobar contains foo 2 times. This functionality is enabled by providing minOccurrences option (defaults to 1). Also refactored the implementation to be based on regex, rather than indexOf.

Checklist

  • PR contains only changes related; no stray files, etc.
  • README updated (where applicable)
  • Tests written (where applicable)

@codecov
Copy link

codecov bot commented Oct 29, 2021

Codecov Report

Merging #1836 (61a3b48) into master (13651ea) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master     #1836   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          102       102           
  Lines         2029      2030    +1     
  Branches       457       459    +2     
=========================================
+ Hits          2029      2030    +1     
Impacted Files Coverage Δ
src/lib/contains.js 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 13651ea...61a3b48. Read the comment docs.

profnandaa
profnandaa previously approved these changes Oct 30, 2021
Copy link
Member

@profnandaa profnandaa left a comment

Choose a reason for hiding this comment

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

LGTM.

@tux-tn @ezkemboi can take a look.

@profnandaa profnandaa added needs-more-review ready-to-land For PRs that are reviewed and ready to be landed labels Oct 30, 2021
src/lib/contains.js Outdated Show resolved Hide resolved
@profnandaa
Copy link
Member

@tux-tn -- need your final ✅

Copy link
Member

@tux-tn tux-tn left a comment

Choose a reason for hiding this comment

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

LGTM 🎉
Thank you @Marcholio for all your recent contributions ❤️

@profnandaa profnandaa merged commit 769f6d5 into validatorjs:master Oct 31, 2021
profnandaa pushed a commit that referenced this pull request Oct 31, 2021
…ltiple times (#1836)

* Added feature to require minimum number of occurrences for the seed in 'contains'

* Changed regex to split

Co-authored-by: Markus Tyrkkö <markus.tyrkko@nitor.com>
Co-authored-by: Markus <markus.tyrkko@gmail.com>
profnandaa pushed a commit that referenced this pull request Oct 31, 2021
…ltiple times (#1836)

* Added feature to require minimum number of occurrences for the seed in 'contains'

* Changed regex to split

Co-authored-by: Markus Tyrkkö <markus.tyrkko@nitor.com>
Co-authored-by: Markus <markus.tyrkko@gmail.com>
@Marcholio Marcholio deleted the feature/count-of-hits branch October 31, 2021 08:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-more-review ready-to-land For PRs that are reviewed and ready to be landed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants