Skip to content

Merge all option sanitation functions into xpns_opt_checker()#190

Merged
greymd merged 5 commits intogreymd:masterfrom
ReDTerraN:checkfunc
Apr 16, 2023
Merged

Merge all option sanitation functions into xpns_opt_checker()#190
greymd merged 5 commits intogreymd:masterfrom
ReDTerraN:checkfunc

Conversation

@ReDTerraN
Copy link
Contributor

With this change we remove four of the sanitation functions, to instead have a single main function for this purpose.
We are by default expecting an integer, if not an integer we are utilizing an additional positional parameters such as "csv" "string" or "float", which then changes the _pattern variable (except for string where we check if its populated).

With this change we can now scale much better and has the ability to add additional option sanitation checks easily with just another elif case.

@greymd
Copy link
Owner

greymd commented Apr 15, 2023

Nice.
I have added some unit tests for the function in eab9851 , which you can try with bash unit.sh.

This PR will be merged in the next few days.
But if you come up with any test cases, please do update it.

@ReDTerraN
Copy link
Contributor Author

ReDTerraN commented Apr 15, 2023

Great addition, If I get time I will take a look if we can create more unit tests for it.

@ReDTerraN
Copy link
Contributor Author

in 0b220f3 I solidified the integer regex, this to make sure that we do not get weird behavior if people are applying floats or multiple dots to the options that expect integers. I have added these cases as test as well, combined with one for csv if the beginning is correct but wrong format comes later in the csv.

@greymd greymd merged commit 0d9089b into greymd:master Apr 16, 2023
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.

2 participants