mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2025-01-19 01:35:28 +01:00
Add fill/no fill for schema props
This commit is contained in:
parent
dcd81102fa
commit
ed9accc1e4
@ -9,27 +9,111 @@ from app.classes.web.base_api_handler import BaseApiHandler
|
||||
config_json_schema = {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"https_port": {"type": "integer", "error": "typeInteger"},
|
||||
"language": {"type": "string", "error": "typeString"},
|
||||
"cookie_expire": {"type": "integer", "error": "typeInteger"},
|
||||
"show_errors": {"type": "boolean", "error": "typeBool"},
|
||||
"history_max_age": {"type": "integer", "error": "typeInteger"},
|
||||
"stats_update_frequency_seconds": {"type": "integer", "error": "typeInteger"},
|
||||
"delete_default_json": {"type": "boolean", "error": "typeBool"},
|
||||
"show_contribute_link": {"type": "boolean", "error": "typeBool"},
|
||||
"virtual_terminal_lines": {"type": "integer", "error": "typeInteger"},
|
||||
"max_log_lines": {"type": "integer", "error": "typeInteger"},
|
||||
"max_audit_entries": {"type": "integer", "error": "typeInteger"},
|
||||
"disabled_language_files": {"type": "array", "error": "typeList"},
|
||||
"stream_size_GB": {"type": "integer", "error": "typeInteger"},
|
||||
"keywords": {"type": "array", "error": "typeList"},
|
||||
"allow_nsfw_profile_pictures": {"type": "boolean", "error": "typeBool"},
|
||||
"enable_user_self_delete": {"type": "boolean", "error": "typeBool"},
|
||||
"reset_secrets_on_next_boot": {"type": "boolean", "error": "typeBool"},
|
||||
"monitored_mounts": {"type": "array", "error": "typeList"},
|
||||
"dir_size_poll_freq_minutes": {"type": "integer", "error": "typeInteger"},
|
||||
"crafty_logs_delete_after_days": {"type": "integer", "error": "typeInteger"},
|
||||
"big_bucket_repo": {"type": "string", "error": "typeString"},
|
||||
"https_port": {
|
||||
"type": "integer",
|
||||
"error": "typeInteger",
|
||||
"fill": True,
|
||||
},
|
||||
"language": {
|
||||
"type": "string",
|
||||
"error": "typeString",
|
||||
"fill": True,
|
||||
},
|
||||
"cookie_expire": {
|
||||
"type": "integer",
|
||||
"error": "typeInteger",
|
||||
"fill": True,
|
||||
},
|
||||
"show_errors": {
|
||||
"type": "boolean",
|
||||
"error": "typeBool",
|
||||
"fill": True,
|
||||
},
|
||||
"history_max_age": {
|
||||
"type": "integer",
|
||||
"error": "typeInteger",
|
||||
"fill": True,
|
||||
},
|
||||
"stats_update_frequency_seconds": {
|
||||
"type": "integer",
|
||||
"error": "typeInteger",
|
||||
"fill": True,
|
||||
},
|
||||
"delete_default_json": {
|
||||
"type": "boolean",
|
||||
"error": "typeBool",
|
||||
"fill": True,
|
||||
},
|
||||
"show_contribute_link": {
|
||||
"type": "boolean",
|
||||
"error": "typeBool",
|
||||
"fill": True,
|
||||
},
|
||||
"virtual_terminal_lines": {
|
||||
"type": "integer",
|
||||
"error": "typeInteger",
|
||||
"fill": True,
|
||||
},
|
||||
"max_log_lines": {
|
||||
"type": "integer",
|
||||
"error": "typeInteger",
|
||||
"fill": True,
|
||||
},
|
||||
"max_audit_entries": {
|
||||
"type": "integer",
|
||||
"error": "typeInteger",
|
||||
"fill": True,
|
||||
},
|
||||
"disabled_language_files": {
|
||||
"type": "array",
|
||||
"error": "typeList",
|
||||
"fill": True,
|
||||
},
|
||||
"stream_size_GB": {
|
||||
"type": "integer",
|
||||
"error": "typeInteger",
|
||||
"fill": True,
|
||||
},
|
||||
"keywords": {
|
||||
"type": "array",
|
||||
"error": "typeList",
|
||||
"fill": True,
|
||||
},
|
||||
"allow_nsfw_profile_pictures": {
|
||||
"type": "boolean",
|
||||
"error": "typeBool",
|
||||
"fill": True,
|
||||
},
|
||||
"enable_user_self_delete": {
|
||||
"type": "boolean",
|
||||
"error": "typeBool",
|
||||
"fill": True,
|
||||
},
|
||||
"reset_secrets_on_next_boot": {
|
||||
"type": "boolean",
|
||||
"error": "typeBool",
|
||||
"fill": True,
|
||||
},
|
||||
"monitored_mounts": {
|
||||
"type": "array",
|
||||
"error": "typeList",
|
||||
"fill": True,
|
||||
},
|
||||
"dir_size_poll_freq_minutes": {
|
||||
"type": "integer",
|
||||
"error": "typeInteger",
|
||||
"fill": True,
|
||||
},
|
||||
"crafty_logs_delete_after_days": {
|
||||
"type": "integer",
|
||||
"error": "typeInteger",
|
||||
"fill": True,
|
||||
},
|
||||
"big_bucket_repo": {
|
||||
"type": "string",
|
||||
"error": "typeString",
|
||||
"fill": True,
|
||||
},
|
||||
},
|
||||
"additionalProperties": False,
|
||||
"minProperties": 1,
|
||||
@ -37,8 +121,16 @@ config_json_schema = {
|
||||
customize_json_schema = {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"photo": {"type": "string", "error": "typeString"},
|
||||
"opacity": {"type": "string", "error": "typeString"},
|
||||
"photo": {
|
||||
"type": "string",
|
||||
"error": "typeString",
|
||||
"fill": True,
|
||||
},
|
||||
"opacity": {
|
||||
"type": "string",
|
||||
"error": "typeString",
|
||||
"fill": True,
|
||||
},
|
||||
},
|
||||
"additionalProperties": False,
|
||||
"minProperties": 1,
|
||||
@ -47,7 +139,11 @@ customize_json_schema = {
|
||||
photo_delete_schema = {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"photo": {"type": "string", "error": "typeString"},
|
||||
"photo": {
|
||||
"type": "string",
|
||||
"error": "typeString",
|
||||
"fill": True,
|
||||
},
|
||||
},
|
||||
"additionalProperties": False,
|
||||
"minProperties": 1,
|
||||
@ -109,7 +205,9 @@ class ApiCraftyConfigIndexHandler(BaseApiHandler):
|
||||
try:
|
||||
validate(data, config_json_schema)
|
||||
except ValidationError as why:
|
||||
offending_key = why.path[0] if why.path else None
|
||||
offending_key = None
|
||||
if why.get("fill", None):
|
||||
offending_key = why.path[0] if why.path else None
|
||||
err = f"""{self.translator.translate(
|
||||
"validators",
|
||||
why.schema.get("error"),
|
||||
|
@ -17,10 +17,21 @@ files_get_schema = {
|
||||
"type": "string",
|
||||
"minLength": 1,
|
||||
"error": "filesPageLen",
|
||||
"fill": True,
|
||||
},
|
||||
"folder": {"type": "string", "error": "typeString", "fill": True},
|
||||
"upload": {
|
||||
"type": "boolean",
|
||||
"default": "False",
|
||||
"error": "typeBool",
|
||||
"fill": True,
|
||||
},
|
||||
"unzip": {
|
||||
"type": "boolean",
|
||||
"default": "True",
|
||||
"error": "typeBool",
|
||||
"fill": True,
|
||||
},
|
||||
"folder": {"type": "string", "error": "typeString"},
|
||||
"upload": {"type": "boolean", "default": "False", "error": "typeBool"},
|
||||
"unzip": {"type": "boolean", "default": "True", "error": "typeBool"},
|
||||
},
|
||||
"additionalProperties": False,
|
||||
"minProperties": 1,
|
||||
@ -52,7 +63,9 @@ class ApiImportFilesIndexHandler(BaseApiHandler):
|
||||
try:
|
||||
validate(data, files_get_schema)
|
||||
except ValidationError as why:
|
||||
offending_key = why.path[0] if why.path else None
|
||||
offending_key = None
|
||||
if why.get("fill", None):
|
||||
offending_key = why.path[0] if why.path else None
|
||||
err = f"""{self.translator.translate(
|
||||
"validators",
|
||||
why.schema.get("error"),
|
||||
|
@ -17,6 +17,7 @@ create_role_schema = {
|
||||
"servers": {
|
||||
"type": "array",
|
||||
"error": "typeList",
|
||||
"fill": True,
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@ -51,6 +52,7 @@ basic_create_role_schema = {
|
||||
"servers": {
|
||||
"type": "array",
|
||||
"error": "typeList",
|
||||
"fill": True,
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@ -142,13 +144,21 @@ class ApiRolesIndexHandler(BaseApiHandler):
|
||||
validate(data, create_role_schema)
|
||||
else:
|
||||
validate(data, basic_create_role_schema)
|
||||
except ValidationError as e:
|
||||
except ValidationError as why:
|
||||
offending_key = None
|
||||
if why.get("fill", None):
|
||||
offending_key = why.path[0] if why.path else None
|
||||
err = f"""{self.translator.translate(
|
||||
"validators",
|
||||
why.schema.get("error"),
|
||||
self.controller.users.get_user_lang_by_id(auth_data[4]["user_id"]),
|
||||
)} {offending_key}"""
|
||||
return self.finish_json(
|
||||
400,
|
||||
{
|
||||
"status": "error",
|
||||
"error": "INVALID_JSON_SCHEMA",
|
||||
"error_data": str(e),
|
||||
"error_data": f"{str(err)}",
|
||||
},
|
||||
)
|
||||
|
||||
|
@ -16,6 +16,7 @@ modify_role_schema = {
|
||||
"servers": {
|
||||
"type": "array",
|
||||
"error": "typeList",
|
||||
"fill": True,
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@ -50,6 +51,7 @@ basic_modify_role_schema = {
|
||||
"servers": {
|
||||
"type": "array",
|
||||
"error": "typeList",
|
||||
"fill": True,
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@ -173,13 +175,21 @@ class ApiRolesRoleIndexHandler(BaseApiHandler):
|
||||
validate(data, modify_role_schema)
|
||||
else:
|
||||
validate(data, basic_modify_role_schema)
|
||||
except ValidationError as e:
|
||||
except ValidationError as why:
|
||||
offending_key = None
|
||||
if why.get("fill", None):
|
||||
offending_key = why.path[0] if why.path else None
|
||||
err = f"""{self.translator.translate(
|
||||
"validators",
|
||||
why.schema.get("error"),
|
||||
self.controller.users.get_user_lang_by_id(auth_data[4]["user_id"]),
|
||||
)} {offending_key}"""
|
||||
return self.finish_json(
|
||||
400,
|
||||
{
|
||||
"status": "error",
|
||||
"error": "INVALID_JSON_SCHEMA",
|
||||
"error_data": str(e),
|
||||
"error_data": f"{str(err)}",
|
||||
},
|
||||
)
|
||||
|
||||
|
@ -668,12 +668,13 @@
|
||||
"uses": "Number of uses allowed (-1==No Limit)"
|
||||
},
|
||||
"validators": {
|
||||
"filesPageLen": "Length must be greater than 1 for property ",
|
||||
"filesPageLen": "Length must be greater than 1 for property for prop",
|
||||
"passLength": "Password Too Short. Minimum Length: 8",
|
||||
"roleManager": "Role manager must be of type integer (manager ID) or None",
|
||||
"roleName": "Role name must be a string that is greater than 1 character. It must not include any of the following symbols: [ ] , ",
|
||||
"roleServerId": "Server ID property must be a string with a minimum length of 1",
|
||||
"roleServerPerms": "Server permissions must be an 8-bit string",
|
||||
"serverCreateName": "Server name must be a string with a minimum length of 2 and must not include: \\ / or # ",
|
||||
"typeBool": "Type error: True or False required for ",
|
||||
"typeInteger": "Type error: Integer required for ",
|
||||
"typeList": "Type error: List required for ",
|
||||
|
Loading…
x
Reference in New Issue
Block a user