-
Notifications
You must be signed in to change notification settings - Fork 92
[feature] added rule for currency validation #178
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
Conversation
@ishan-srivastava thank you for your job on this PR. Since you are using regex for testing, I think it would be hard to cover all types. The easier way can be that if we can set different checker regexp in the rule params. What do you think @ishan-srivastava @erfanium ? |
Sure @icebob , that makes sense.
What we can also do is to extend the regex for the end-user to provide (in the schema), and that would override all the inbuilt validations the currency validator does, and would simply check the provided value against the regex provided by the user. |
Yeah, and please support negative currencies as well. I didn't see tests for negative values. |
This is a good idea, But I don't think we need to support all currencies, We can first support some important currencies and wait for user issues/PRs 🙂 This can be even more complicated, For example in Iran we have two major currencies: Rial and Toman Which can be converted into each other (10 Rial = 1 Toman). so maybe it is even better to have a separate rules for each currency. |
@erfanium sure. @erfanium @icebob Should I go ahead and add the changes I suggested, or just simply support -ve values and update the PR? |
As @erfanium said, we don't need to support all currencies. So as you described, just add some property like thousand separator and decimal separator and a custom regexp pattern. So if I want to check Hungarian forint with this rule, I will define a custom regexp and set it to the rule. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As @erfanium said, we don't need to support all currencies. So as you described, just add some property like thousand separator and decimal separator and a custom regexp pattern. So if I want to check Hungarian forint with this rule, I will define a custom regexp and set it to the rule.
Sure, I'll add that in this week, day job has turned v hectic :p |
cfbd715
to
51b0715
Compare
@icebob I have added the following
Please have a look. |
@icebob What's the status of this PR? |
It's waiting for my review. I was busy but I will review it this week. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job @ishan-srivastava, thanks!
Released in 1.7.0 |
Regarding this feature request.