Increase video attributes length

Number of tags: 3 -> 5
Tag length: 10 -> 30
Video name: 50 -> 120
Video channel name: 50 -> 120
pull/125/head
Chocobozzz 2017-10-26 15:52:11 +02:00
parent a6d947a9f9
commit a265f7f30f
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
7 changed files with 27 additions and 16 deletions

View File

@ -1,11 +1,11 @@
import { Validators } from '@angular/forms' import { Validators } from '@angular/forms'
export const VIDEO_NAME = { export const VIDEO_NAME = {
VALIDATORS: [ Validators.required, Validators.minLength(3), Validators.maxLength(50) ], VALIDATORS: [ Validators.required, Validators.minLength(3), Validators.maxLength(120) ],
MESSAGES: { MESSAGES: {
'required': 'Video name is required.', 'required': 'Video name is required.',
'minlength': 'Video name must be at least 3 characters long.', 'minlength': 'Video name must be at least 3 characters long.',
'maxlength': 'Video name cannot be more than 50 characters long.' 'maxlength': 'Video name cannot be more than 120 characters long.'
} }
} }
@ -45,10 +45,10 @@ export const VIDEO_DESCRIPTION = {
} }
export const VIDEO_TAGS = { export const VIDEO_TAGS = {
VALIDATORS: [ Validators.minLength(2), Validators.maxLength(10) ], VALIDATORS: [ Validators.minLength(2), Validators.maxLength(30) ],
MESSAGES: { MESSAGES: {
'minlength': 'A tag should be more than 2 characters long.', 'minlength': 'A tag should be more than 2 characters long.',
'maxlength': 'A tag should be less than 10 characters long.' 'maxlength': 'A tag should be less than 30 characters long.'
} }
} }

View File

@ -77,7 +77,7 @@
<label class="label-tags">Tags</label> <span class="little-information">(press enter to add the tag)</span> <label class="label-tags">Tags</label> <span class="little-information">(press enter to add the tag)</span>
<tag-input <tag-input
[ngModel]="tags" [validators]="tagValidators" [errorMessages]="tagValidatorsMessages" [ngModel]="tags" [validators]="tagValidators" [errorMessages]="tagValidatorsMessages"
formControlName="tags" maxItems="3" modelAsStrings="true" formControlName="tags" maxItems="5" modelAsStrings="true"
></tag-input> ></tag-input>
</div> </div>

View File

@ -65,7 +65,7 @@
<label for="tags" class="label-tags">Tags</label> <span class="little-information">(press enter to add the tag)</span> <label for="tags" class="label-tags">Tags</label> <span class="little-information">(press enter to add the tag)</span>
<tag-input <tag-input
[ngModel]="tags" [validators]="tagValidators" [errorMessages]="tagValidatorsMessages" [ngModel]="tags" [validators]="tagValidators" [errorMessages]="tagValidatorsMessages"
formControlName="tags" maxItems="3" modelAsStrings="true" formControlName="tags" maxItems="5" modelAsStrings="true"
></tag-input> ></tag-input>
</div> </div>

View File

@ -131,3 +131,4 @@ export class VideoUpdateComponent extends FormReactive implements OnInit {
this.form.patchValue(this.video.toJSON()) this.form.patchValue(this.video.toJSON())
} }
} }

View File

@ -118,17 +118,17 @@ const CONSTRAINTS_FIELDS = {
REASON: { min: 2, max: 300 } // Length REASON: { min: 2, max: 300 } // Length
}, },
VIDEO_CHANNELS: { VIDEO_CHANNELS: {
NAME: { min: 3, max: 50 }, // Length NAME: { min: 3, max: 120 }, // Length
DESCRIPTION: { min: 3, max: 250 } // Length DESCRIPTION: { min: 3, max: 250 } // Length
}, },
VIDEOS: { VIDEOS: {
NAME: { min: 3, max: 50 }, // Length NAME: { min: 3, max: 120 }, // Length
DESCRIPTION: { min: 3, max: 250 }, // Length DESCRIPTION: { min: 3, max: 250 }, // Length
EXTNAME: [ '.mp4', '.ogv', '.webm' ], EXTNAME: [ '.mp4', '.ogv', '.webm' ],
INFO_HASH: { min: 40, max: 40 }, // Length, info hash is 20 bytes length but we represent it in hexadecimal so 20 * 2 INFO_HASH: { min: 40, max: 40 }, // Length, info hash is 20 bytes length but we represent it in hexadecimal so 20 * 2
DURATION: { min: 1, max: 7200 }, // Number DURATION: { min: 1, max: 7200 }, // Number
TAGS: { min: 0, max: 3 }, // Number of total tags TAGS: { min: 0, max: 5 }, // Number of total tags
TAG: { min: 2, max: 10 }, // Length TAG: { min: 2, max: 30 }, // Length
THUMBNAIL: { min: 2, max: 30 }, THUMBNAIL: { min: 2, max: 30 },
THUMBNAIL_DATA: { min: 0, max: 20000 }, // Bytes THUMBNAIL_DATA: { min: 0, max: 20000 }, // Bytes
VIEWS: { min: 0 }, VIEWS: { min: 0 },

View File

@ -119,6 +119,9 @@ describe('Test videos API validator', function () {
it('Should fail with a long name', async function () { it('Should fail with a long name', async function () {
const fields = { const fields = {
name: 'hello tooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo' + name: 'hello tooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo' +
'oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo' +
'oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo' +
'oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo' +
'oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo long', 'oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo long',
description: 'super description' description: 'super description'
} }
@ -178,6 +181,9 @@ describe('Test videos API validator', function () {
it('Should fail with a long name', async function () { it('Should fail with a long name', async function () {
const fields = { const fields = {
name: 'hello tooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo' + name: 'hello tooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo' +
'oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo' +
'oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo' +
'oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo' +
'oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo long', 'oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo long',
description: 'super description' description: 'super description'
} }

View File

@ -124,7 +124,9 @@ describe('Test videos API validator', function () {
it('Should fail with a long name', async function () { it('Should fail with a long name', async function () {
const fields = { const fields = {
name: 'My very very very very very very very very very very very very very very very very long name', name: 'My very very very very very very very very very very very very very very very very very ' +
'very very very very very very very very very very very very very very very very long long' +
'very very very very very very very very very very very very very very very very long name',
category: 5, category: 5,
licence: 1, licence: 1,
language: 6, language: 6,
@ -358,7 +360,7 @@ describe('Test videos API validator', function () {
language: 6, language: 6,
nsfw: false, nsfw: false,
description: 'my super description', description: 'my super description',
tags: [ 'tag1', 'tag2', 'tag3', 'tag4' ], tags: [ 'tag1', 'tag2', 'tag3', 'tag4', 'tag5', 'tag6' ],
channelId channelId
} }
const attaches = { const attaches = {
@ -392,7 +394,7 @@ describe('Test videos API validator', function () {
language: 6, language: 6,
nsfw: false, nsfw: false,
description: 'my super description', description: 'my super description',
tags: [ 'my_super_tag_too_long', 'tag1' ], tags: [ 'my_super_tag_too_long_long_long_long_long_long', 'tag1' ],
channelId channelId
} }
const attaches = { const attaches = {
@ -543,7 +545,9 @@ describe('Test videos API validator', function () {
it('Should fail with a long name', async function () { it('Should fail with a long name', async function () {
const fields = { const fields = {
name: 'My very very very very very very very very very very very very very very very very long name', name: 'My very very very very very very very very very very very very very very very very very ' +
'very very very very very very very very very very very very very very very very long long' +
'very very very very very very very very very very very very very very very very long name',
category: 5, category: 5,
licence: 2, licence: 2,
language: 6, language: 6,
@ -629,7 +633,7 @@ describe('Test videos API validator', function () {
language: 6, language: 6,
nsfw: false, nsfw: false,
description: 'my super description', description: 'my super description',
tags: [ 'tag1', 'tag2', 'tag3', 'tag4' ] tags: [ 'tag1', 'tag2', 'tag3', 'tag4', 'tag5', 'tag6' ]
} }
await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields }) await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields })
}) })
@ -655,7 +659,7 @@ describe('Test videos API validator', function () {
language: 6, language: 6,
nsfw: false, nsfw: false,
description: 'my super description', description: 'my super description',
tags: [ 'my_super_tag_too_long', 'tag1' ] tags: [ 'my_super_tag_too_long_long_long_long', 'tag1' ]
} }
await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields }) await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields })
}) })