Adds validation for colors when editing/creating tags, and creates the INVALID_COLOR error

This commit is contained in:
Maxi Redigonda 2019-10-14 10:02:01 -03:00
parent 22efd7ea93
commit ec3b1ec32a
3 changed files with 13 additions and 0 deletions

View File

@ -36,6 +36,10 @@ class CreateTagController extends Controller {
'name' => [
'validation' => DataValidator::length(2, 100),
'error' => ERRORS::INVALID_NAME
],
'color' => [
'validation' => DataValidator::hexRgbColor()->startsWith('#'),
'error' => ERRORS::INVALID_COLOR
]
]
];

View File

@ -37,6 +37,10 @@ class EditTagController extends Controller {
'tagId' => [
'validation' => DataValidator::dataStoreId('tag'),
'error' => ERRORS::INVALID_TAG
],
'color' => [
'validation' => DataValidator::hexRgbColor()->startsWith('#'),
'error' => ERRORS::INVALID_COLOR
]
]
];

View File

@ -247,6 +247,10 @@
* @apiDefine UNAVAILABLE_STATS
* @apiError {String} UNAVAILABLE_STATS Stats are currently unavailable
*/
/**
* @apiDefine INVALID_COLOR
* @apiError {String} INVALID_COLOR The color should be in hexadecimal, preceded by a '#'
*/
class ERRORS {
const INVALID_CREDENTIALS = 'INVALID_CREDENTIALS';
@ -312,4 +316,5 @@ class ERRORS {
const INVALID_CUSTOM_FIELD_OPTIONS = 'INVALID_CUSTOM_FIELD_OPTIONS';
const INVALID_CUSTOM_FIELD_OPTION = 'INVALID_CUSTOM_FIELD_OPTION';
const UNAVAILABLE_STATS = 'UNAVAILABLE_STATS';
const INVALID_COLOR = 'INVALID_COLOR';
}