-
Notifications
You must be signed in to change notification settings - Fork 0
Bugfix/validate date #104
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
Merged
Merged
Bugfix/validate date #104
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
d5af49b
add custom decorator
spiftire 4d67366
Merge branch 'feature/default-enums' into bugfix/validate-date
spiftire 81a9257
remove unused code
spiftire 4d8fd93
add new tests
spiftire 69a4753
fix validator
spiftire 451395d
add test debugger
spiftire 22b603e
add new tests
spiftire dc88c92
add options
spiftire 237260f
Add decorators to opendate
spiftire 5e8c12b
add validation group to createElection
spiftire ec91701
Merge branch 'develop' into bugfix/validate-date
spiftire d986421
move file
spiftire 0ba0691
fix imports
spiftire 8456cab
add new tests to entity
spiftire dfb48ea
fix validation options
spiftire f24f2b1
fix if statment
spiftire 0edfccd
fix test
spiftire abbe03f
set validator options
spiftire 36ca7e7
Merge branch 'develop' into bugfix/validate-date
spiftire a0b1b64
fix method access
spiftire 49ffae0
fix tests
spiftire 1440426
fix method call
spiftire File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| import { registerDecorator, ValidationOptions, ValidationArguments } from 'class-validator' | ||
|
|
||
| export function IsEarlierThan(property: string, validationOptions?: ValidationOptions) { | ||
| return function (object: Object, propertyName: string) { | ||
| registerDecorator({ | ||
| name: 'isEarlierThan', | ||
| target: object.constructor, | ||
| propertyName: propertyName, | ||
| constraints: [property], | ||
| options: validationOptions, | ||
| validator: { | ||
| validate(value: any, args: ValidationArguments) { | ||
| const [relatedPropertyName] = args.constraints | ||
| const relatedValue = (args.object as any)[relatedPropertyName] | ||
| if (!value || !relatedValue) return true | ||
| return value <= relatedValue // you can return a Promise<boolean> here as well, if you want to make async validation | ||
| } | ||
| } | ||
| }) | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This should probably be set by default