-
Notifications
You must be signed in to change notification settings - Fork 36
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
checking numbers in range and text at the same time #28
Comments
Hi @cnarvaa. This is mostly a by-product of the fact that I use vectorized operations wherever possible in PandasSchema, meaning that I can't look at each element individually to check if it's a number or not in the same operation. It also means I can't use your exact code because it's not vectorized. The ideal way I'd want this to work is using an InListValidation(['a', '-']) | InRangeValidation(0, MAX_SCORE) However, it is a problem that the |
I would also like to receive the exact reason why a value doesn't accomplish a rule when I use the boolean operators. I was checking the code but I don't get were to change that. |
Under the current version, you can probably do this: v = InListValidation(['a', '-']) | InRangeValidation(0, MAX_SCORE)
v._custom_message = 'Your custom message' However that's a bit ugly, and there should be a way of setting a custom message as part of the constructor. What I might aim to do is improve the
Then I'll have to actually add |
Well, the main idea is to know the exact reason (condition) why Validation is false. Using a generic message is not correct for us in this moment. Maybe something in between the moment we get the first false? |
Yes, I understand you want a message that explains why the validation failed. But you can specify anything in the custom message: v._custom_message = 'was not in the range (0, 100) and also was not one of the allowed characters "a" or "-"'
Can you explain what you mean by this? |
Hey Miguel, We are getting this message as validation error Using a custom message, like the example you show me, is not pretty clear for the users. It's more clear if they know exactly what they did wrong. We are doing some tricks on our side but I think this could be a good feature. I will check the _CombinedValidation function and then I can share an Idea. EditI just checked the logic in Perhaps, even if we can set something like I don't know if you have any idea about this. By now, I'm letting it go! |
Ah okay, I see your point. You want the message to only mention validations that actually failed, not the others that passed. I agree with that, for what it's worth. Since it's a bit tricky to do, it's something I'm endeavouring to fix in the next major version, which is currently in the form of this PR: https://github.com/TMiguelT/PandasSchema/pull/29/files. |
Update: this is half fixed by #30, but it still returns both validation messages if only one validation fails, so this is still an ongoing issue. |
Hey, I'm very thankful for this library, it makes lots of things easier for us 😄 .
Well, at this moment we have to validate that a cell contains "a, -, 4.5". And, if the cell has a number, that number must be between 0 and 10.
The problem is that, since we have some chars there, we can not use the range
InRangeValidation
. The error saysUnable to parse string "-" at position 4
.I was able to fix this using
It seems like a very straigth forward answer, but it works.
Some advice? should I implement this and publish a PR?
The text was updated successfully, but these errors were encountered: