-
-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #452 from Rishikant181/dev
v2.5.1
- Loading branch information
Showing
7 changed files
with
121 additions
and
31 deletions.
There are no files selected for viewing
This file contains 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 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 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 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,98 @@ | ||
// PACKAGES | ||
import { | ||
ArrayMaxSize, | ||
IsArray, | ||
IsNotEmpty, | ||
IsNumberString, | ||
IsObject, | ||
IsOptional, | ||
IsString, | ||
MaxLength, | ||
validateSync, | ||
} from 'class-validator'; | ||
import { DataValidationError } from 'rettiwt-core'; | ||
|
||
/** | ||
* The arguments specifying the tweet to be posted. | ||
*/ | ||
export class TweetArgs { | ||
/** | ||
* The text content of the tweet. | ||
* | ||
* @remarks Length must be \<= 280 characters. | ||
*/ | ||
@IsNotEmpty() | ||
@IsString() | ||
@MaxLength(280) | ||
public text: string; | ||
|
||
/** | ||
* The media content of the tweet. | ||
* | ||
* @remarks Max number of media that can be posted is 4. | ||
*/ | ||
@IsOptional() | ||
@IsArray() | ||
@ArrayMaxSize(4) | ||
@IsObject({ each: true }) | ||
public media?: TweetMediaArgs[]; | ||
|
||
/** | ||
* @param tweet - The tweet arguments specifying the tweet. | ||
*/ | ||
public constructor(tweet: TweetArgs) { | ||
this.text = tweet.text; | ||
this.media = tweet.media ? tweet.media.map((item) => new TweetMediaArgs(item)) : undefined; | ||
|
||
// Validating this object | ||
const validationResult = validateSync(this); | ||
|
||
// If validation error occured | ||
if (validationResult.length) { | ||
throw new DataValidationError(validationResult); | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* The arguments specifying the media to be posted in a single tweet. | ||
* | ||
* @public | ||
*/ | ||
export class TweetMediaArgs { | ||
/** | ||
* The path to the media file. | ||
* | ||
* @remarks The size of the media file must be \<= 5242880 bytes. | ||
*/ | ||
@IsNotEmpty() | ||
@IsString() | ||
public path: string; | ||
|
||
/** | ||
* The list of id of users to be tagged in the media. | ||
* | ||
* @remarks Max number of tags is 10. | ||
*/ | ||
@IsOptional() | ||
@IsArray() | ||
@ArrayMaxSize(10) | ||
@IsNumberString(undefined, { each: true }) | ||
public tags?: string[]; | ||
|
||
/** | ||
* @param media - The media arguments specifying the media. | ||
*/ | ||
public constructor(media: TweetMediaArgs) { | ||
this.path = media.path; | ||
this.tags = media.tags ?? []; | ||
|
||
// Validating this object | ||
const validationResult = validateSync(this); | ||
|
||
// If validation error occured | ||
if (validationResult.length) { | ||
throw new DataValidationError(validationResult); | ||
} | ||
} | ||
} |
This file contains 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 was deleted.
Oops, something went wrong.
This file contains 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 |
---|---|---|
|
@@ -343,7 +343,7 @@ chokidar@^3.5.2: | |
optionalDependencies: | ||
fsevents "~2.3.2" | ||
|
||
[email protected]: | ||
[email protected], class-validator@^0.14.1: | ||
version "0.14.1" | ||
resolved "https://registry.yarnpkg.com/class-validator/-/class-validator-0.14.1.tgz#ff2411ed8134e9d76acfeb14872884448be98110" | ||
integrity sha512-2VEG9JICxIqTpoK1eMzZqaV+u/EiwEJkMGzTrZf6sU/fwsnOITVgYJ8yojSy6CaXtO9V0Cc6ZQZ8h8m4UBuLwQ== | ||
|
@@ -1090,10 +1090,10 @@ [email protected]: | |
cookiejar "2.1.4" | ||
https-proxy-agent "7.0.2" | ||
|
||
[email protected].0: | ||
version "3.3.0" | ||
resolved "https://registry.yarnpkg.com/rettiwt-core/-/rettiwt-core-3.3.0.tgz#c856b1be47137c5289da65edd4560f2d95a76d73" | ||
integrity sha512-m75NzF9eGO/2mxRJpakWF7nmSjXyaYuGLIxKlekP0xl5MNZNKlE3r/yV0lHADZOajCkW+XYXN7AbB0lphgOoMg== | ||
[email protected].1: | ||
version "3.3.1" | ||
resolved "https://registry.yarnpkg.com/rettiwt-core/-/rettiwt-core-3.3.1.tgz#09ab32e66ba5b55d9ba9896e8dcd780f1b1f4e50" | ||
integrity sha512-TNJFM1UQyfGT8FXPeqePMUk7qzBfoet2/Nzn7+Ma4ibyKdn+XCqaA1c10se02qYomQ7Lolc/KCZvhUPjwCJFXQ== | ||
dependencies: | ||
axios "1.6.3" | ||
class-validator "0.14.1" | ||
|