-
Notifications
You must be signed in to change notification settings - Fork 809
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: add isLatLong, isLatitude, isLongtitude validators #427
Conversation
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.
Also please update docs
I was thinking about this and maybe we should also add Also please could you ad default error messages for all new validators. |
Okay sure. About the islatitude and islongitude, I can work it in another or starting tomorrow |
@vlapo added the default error message. sorry about that |
Please add it in this PR and thanks for your contributions. |
@vlapo I have done it please check |
What have you done? I do not see |
added the default message for the pr above. I was thinking of separating the islongitude and islatitude in another PR @vlapo or do you want me to do that in this pr itself? |
No, please do it in this PR. |
okay sure. I will ping you after that |
@vlapo its complete |
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.
And again, docs and default error messages...
I have fixed all the issues that you have mentioned @vlapo |
README.md
Outdated
| `@IsLatitude()` | check if the string is a valid latitude coordinate | ||
| `@IsLongitude()` | check if the string is a valid longitude coordinate |
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.
-
For
@IsLatitude
and@IsLongitude
- string or number -check if the string or number is a valid latitude/longitude coordinate
-
Again formatting. There is more spaces than is necessary. Should be:
| `@IsLatLong()` | check if the string is a valid latitude-longitude coordinate in the format lat,long
| `@IsLatitude()` | check if the string is a valid latitude coordinate
| `@IsLongitude()` | check if the string is a valid longitude coordinate
const validValues = ["85.3446311", "85.2100893"]; | ||
const invalidValues = ["853446311", "as.as12"]; |
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.
Add also valid/invalid number values.
src/validation/Validator.ts
Outdated
|
||
|
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.
Extra lines between comment and function - why?
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.
just wanted to make it look clear on my ide
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.
Sorry but extra empty lines between comment and function related directly to comment do not look clearly. It is pointless :) Check another code in class-validator
and try to use same formatting as we use before in our code base.
src/validation/Validator.ts
Outdated
/** | ||
* Checks if a given value is a longitude. | ||
*/ | ||
|
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.
Extra lines between comment and function - why?
src/validation/Validator.ts
Outdated
|
||
isLongitude(value: any): boolean { | ||
return (typeof value === "number" || this.isString(value)) && this.isLatLong(`${value},0`); | ||
|
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.
Another extra line - why?
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.
@rubiin why did you format all code?!? Format only code you change/add/edit!
my editor formated those so i rerolled and back to the previous commit and only formated my code |
@vlapo fixed |
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.
I have small formatting issues. But be honest, I do not have energy to request changes again. I will fix it in master. Thank you for your contribution. But please, next time be more precise.
When is this version going to be published to npm? |
Hope this weekend :) |
Hi @vlapo and @rubiin The Because of this, the "$property must be a longitude string or number" |
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
added isLatLong() which is used to check whether a given set of points is latitude and longitude or not. The validation is taken from validator.js