@opinio-dev/models 1.3.1-movie-form.0 → 1.3.1-movie-form.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -18,7 +18,7 @@ export class BaseItemValidator extends BaseValidator {
|
|
|
18
18
|
* @returns {Record<string, string>} A record of validation errors.
|
|
19
19
|
*/
|
|
20
20
|
_validateBaseFields(item) {
|
|
21
|
-
const { id, type, name, releaseYear } = item;
|
|
21
|
+
const { id, type, name, releaseYear, imageUrl } = item;
|
|
22
22
|
const errors = {};
|
|
23
23
|
if (!id) {
|
|
24
24
|
errors.id = 'Item id is required';
|
|
@@ -36,6 +36,9 @@ export class BaseItemValidator extends BaseValidator {
|
|
|
36
36
|
if (releaseYear && (releaseYear < 1800 || releaseYear > currentYear)) {
|
|
37
37
|
errors.releaseYear = `Release year must be between 1800 and ${currentYear}`;
|
|
38
38
|
}
|
|
39
|
+
if (!imageUrl) {
|
|
40
|
+
errors.imageUrl = 'Item image url is required';
|
|
41
|
+
}
|
|
39
42
|
return errors;
|
|
40
43
|
}
|
|
41
44
|
}
|
|
@@ -13,7 +13,7 @@ export class BookValidator extends BaseItemValidator {
|
|
|
13
13
|
if (!genres?.length) {
|
|
14
14
|
errors.genres = 'Book genres are required';
|
|
15
15
|
}
|
|
16
|
-
if (!genres?.every((genre) =>
|
|
16
|
+
if (!genres?.every((genre) => BookGenres.includes(genre))) {
|
|
17
17
|
errors.genres = `One or more book genres are invalid. Valid genres are: ${BookGenres.join(', ')}`;
|
|
18
18
|
}
|
|
19
19
|
if (!author) {
|
|
@@ -13,7 +13,7 @@ export class GameValidator extends BaseItemValidator {
|
|
|
13
13
|
if (!genres?.length) {
|
|
14
14
|
errors.genres = 'Game genres are required';
|
|
15
15
|
}
|
|
16
|
-
if (!genres?.every((genre) =>
|
|
16
|
+
if (!genres?.every((genre) => GameGenres.includes(genre))) {
|
|
17
17
|
errors.genres = `One or more game genres are invalid. Valid genres are: ${GameGenres.join(', ')}`;
|
|
18
18
|
}
|
|
19
19
|
if (!platforms?.length) {
|
|
@@ -13,7 +13,7 @@ export class MovieValidator extends BaseItemValidator {
|
|
|
13
13
|
if (!genres?.length) {
|
|
14
14
|
errors.genres = 'Movie genres are required';
|
|
15
15
|
}
|
|
16
|
-
if (!genres?.every((genre) =>
|
|
16
|
+
if (!genres?.every((genre) => VideoGenres.includes(genre))) {
|
|
17
17
|
errors.genres = `One or more movie genres are invalid. Valid genres are: ${VideoGenres.join(', ')}`;
|
|
18
18
|
}
|
|
19
19
|
if (duration === undefined) {
|
|
@@ -14,7 +14,7 @@ export class SeriesValidator extends BaseItemValidator {
|
|
|
14
14
|
if (!genres?.length) {
|
|
15
15
|
errors.genres = 'Series genres are required';
|
|
16
16
|
}
|
|
17
|
-
if (!genres?.every((genre) =>
|
|
17
|
+
if (!genres?.every((genre) => VideoGenres.includes(genre))) {
|
|
18
18
|
errors.genres = `One or more series genres are invalid. Valid genres are: ${VideoGenres.join(', ')}`;
|
|
19
19
|
}
|
|
20
20
|
if (!status) {
|