Enable enum errors

This commit is contained in:
amcmanu3 2024-08-06 14:44:01 -04:00
parent 279ad61a1b
commit 2520e4b00f
10 changed files with 80 additions and 79 deletions

View File

@ -205,14 +205,14 @@ class ApiCraftyConfigIndexHandler(BaseApiHandler):
try:
validate(data, config_json_schema)
except ValidationError as why:
offending_key = None
if why.get("fill", None):
offending_key = ""
if why.schema.get("fill", None):
offending_key = why.path[0] if why.path else None
err = f"""{self.translator.translate(
err = f"""{offending_key} {self.translator.translate(
"validators",
why.schema.get("error"),
self.controller.users.get_user_lang_by_id(auth_data[4]["user_id"]),
)} {offending_key}"""
)} {why.schema.get("enum", "")}"""
return self.finish_json(
400,
{

View File

@ -63,14 +63,14 @@ class ApiImportFilesIndexHandler(BaseApiHandler):
try:
validate(data, files_get_schema)
except ValidationError as why:
offending_key = None
if why.get("fill", None):
offending_key = ""
if why.schema.get("fill", None):
offending_key = why.path[0] if why.path else None
err = f"""{self.translator.translate(
err = f"""{offending_key} {self.translator.translate(
"validators",
why.schema.get("error"),
self.controller.users.get_user_lang_by_id(auth_data[4]["user_id"]),
)} {offending_key}"""
)} {why.schema.get("enum", "")}"""
return self.finish_json(
400,
{

View File

@ -145,14 +145,14 @@ class ApiRolesIndexHandler(BaseApiHandler):
else:
validate(data, basic_create_role_schema)
except ValidationError as why:
offending_key = None
if why.get("fill", None):
offending_key = ""
if why.schema.get("fill", None):
offending_key = why.path[0] if why.path else None
err = f"""{self.translator.translate(
err = f"""{offending_key} {self.translator.translate(
"validators",
why.schema.get("error"),
self.controller.users.get_user_lang_by_id(auth_data[4]["user_id"]),
)} {offending_key}"""
)} {why.schema.get("enum", "")}"""
return self.finish_json(
400,
{

View File

@ -176,14 +176,14 @@ class ApiRolesRoleIndexHandler(BaseApiHandler):
else:
validate(data, basic_modify_role_schema)
except ValidationError as why:
offending_key = None
if why.get("fill", None):
offending_key = ""
if why.schema.get("fill", None):
offending_key = why.path[0] if why.path else None
err = f"""{self.translator.translate(
err = f"""{offending_key} {self.translator.translate(
"validators",
why.schema.get("error"),
self.controller.users.get_user_lang_by_id(auth_data[4]["user_id"]),
)} {offending_key}"""
)} {why.schema.get("enum", "")}"""
return self.finish_json(
400,
{

View File

@ -80,7 +80,7 @@ new_server_schema = {
"type": "string",
"default": "minecraft_java",
"enum": ["minecraft_java", "minecraft_bedrock", "none"],
"error": "serverAPI",
"error": "enumErr",
"fill": True,
# TODO: SteamCMD, RakNet, etc.
},
@ -140,7 +140,7 @@ new_server_schema = {
"type": "string",
"default": "minecraft_java",
"enum": ["minecraft_java", "minecraft_bedrock", "custom"],
"error": "serverAPI",
"error": "enumErr",
"fill": True,
},
"minecraft_java_create_data": {
@ -153,13 +153,13 @@ new_server_schema = {
"type": "string",
"default": "download_jar",
"enum": ["download_jar", "import_server", "import_zip"],
"error": "serverAPI",
"error": "enumErr",
"fill": True,
},
"download_jar_create_data": {
"title": "JAR download data",
"type": "object",
"error": "serverAPI",
"error": "enumErr",
"fill": True,
"required": [
"type",
@ -173,7 +173,7 @@ new_server_schema = {
"title": "Jar Category",
"type": "string",
"examples": ["Mc_java_servers", "Mc_java_proxies"],
"error": "serverAPI",
"error": "enumErr",
"fill": True,
},
"properties": {
@ -232,7 +232,7 @@ new_server_schema = {
"import_server_create_data": {
"title": "Import server data",
"type": "object",
"error": "serverAPI",
"error": "enumErr",
"fill": True,
"required": [
"existing_server_path",
@ -299,7 +299,7 @@ new_server_schema = {
"import_zip_create_data": {
"title": "Import ZIP server data",
"type": "object",
"error": "serverAPI",
"error": "enumErr",
"fill": True,
"required": [
"zip_path",
@ -418,13 +418,13 @@ new_server_schema = {
"type": "string",
"default": "import_server",
"enum": ["download_exe", "import_server", "import_zip"],
"error": "serverAPI",
"error": "enumErr",
"fill": True,
},
"download_exe_create_data": {
"title": "Import server data",
"type": "object",
"error": "serverAPI",
"error": "enumErr",
"fill": True,
"required": [],
"properties": {
@ -438,7 +438,7 @@ new_server_schema = {
"import_server_create_data": {
"title": "Import server data",
"type": "object",
"error": "serverAPI",
"error": "enumErr",
"fill": True,
"required": ["existing_server_path", "executable"],
"properties": {
@ -475,7 +475,7 @@ new_server_schema = {
"import_zip_create_data": {
"title": "Import ZIP server data",
"type": "object",
"error": "serverAPI",
"error": "enumErr",
"fill": True,
"required": ["zip_path", "zip_root", "command"],
"properties": {
@ -562,7 +562,7 @@ new_server_schema = {
"custom_create_data": {
"title": "Custom creation data",
"type": "object",
"error": "serverAPI",
"error": "enumErr",
"fill": True,
"required": [
"working_directory",
@ -583,7 +583,7 @@ new_server_schema = {
"title": "Executable Updation",
"description": "Also configurable later on and for other servers",
"type": "object",
"error": "serverAPI",
"error": "enumErr",
"fill": True,
"required": ["enabled", "file", "url"],
"properties": {
@ -616,7 +616,7 @@ new_server_schema = {
"type": "string",
"default": "raw_exec",
"enum": ["raw_exec", "import_server", "import_zip"],
"error": "serverAPI",
"error": "enumErr",
"fill": True,
},
"raw_exec_create_data": {
@ -638,7 +638,7 @@ new_server_schema = {
"import_server_create_data": {
"title": "Import server data",
"type": "object",
"error": "serverAPI",
"error": "enumErr",
"fill": True,
"required": ["existing_server_path", "command"],
"properties": {
@ -665,7 +665,7 @@ new_server_schema = {
"import_zip_create_data": {
"title": "Import ZIP server data",
"type": "object",
"error": "serverAPI",
"error": "enumErr",
"fill": True,
"required": ["zip_path", "zip_root", "command"],
"properties": {
@ -829,14 +829,14 @@ class ApiServersIndexHandler(BaseApiHandler):
try:
validate(data, new_server_schema)
except ValidationError as why:
offending_key = None
if why.get("fill", None):
offending_key = ""
if why.schema.get("fill", None):
offending_key = why.path[0] if why.path else None
err = f"""{self.translator.translate(
err = f"""{offending_key} {self.translator.translate(
"validators",
why.schema.get("error"),
self.controller.users.get_user_lang_by_id(auth_data[4]["user_id"]),
)} {offending_key}"""
)} {why.schema.get("enum", "")}"""
return self.finish_json(
400,
{

View File

@ -276,14 +276,14 @@ class ApiServersServerFilesIndexHandler(BaseApiHandler):
try:
validate(data, file_delete_schema)
except ValidationError as why:
offending_key = None
if why.get("fill", None):
offending_key = ""
if why.schema.get("fill", None):
offending_key = why.path[0] if why.path else None
err = f"""{self.translator.translate(
err = f"""{offending_key} {self.translator.translate(
"validators",
why.schema.get("error"),
self.controller.users.get_user_lang_by_id(auth_data[4]["user_id"]),
)} {offending_key}"""
)} {why.schema.get("enum", "")}"""
return self.finish_json(
400,
{
@ -342,14 +342,14 @@ class ApiServersServerFilesIndexHandler(BaseApiHandler):
try:
validate(data, files_patch_schema)
except ValidationError as why:
offending_key = None
if why.get("fill", None):
offending_key = ""
if why.schema.get("fill", None):
offending_key = why.path[0] if why.path else None
err = f"""{self.translator.translate(
err = f"""{offending_key} {self.translator.translate(
"validators",
why.schema.get("error"),
self.controller.users.get_user_lang_by_id(auth_data[4]["user_id"]),
)} {offending_key}"""
)} {why.schema.get("enum", "")}"""
return self.finish_json(
400,
{
@ -404,14 +404,14 @@ class ApiServersServerFilesIndexHandler(BaseApiHandler):
try:
validate(data, files_create_schema)
except ValidationError as why:
offending_key = None
if why.get("fill", None):
offending_key = ""
if why.schema.get("fill", None):
offending_key = why.path[0] if why.path else None
err = f"""{self.translator.translate(
err = f"""{offending_key} {self.translator.translate(
"validators",
why.schema.get("error"),
self.controller.users.get_user_lang_by_id(auth_data[4]["user_id"]),
)} {offending_key}"""
)} {why.schema.get("enum", "")}"""
return self.finish_json(
400,
{
@ -479,14 +479,14 @@ class ApiServersServerFilesCreateHandler(BaseApiHandler):
try:
validate(data, files_rename_schema)
except ValidationError as why:
offending_key = None
if why.get("fill", None):
offending_key = ""
if why.schema.get("fill", None):
offending_key = why.path[0] if why.path else None
err = f"""{self.translator.translate(
err = f"""{offending_key} {self.translator.translate(
"validators",
why.schema.get("error"),
self.controller.users.get_user_lang_by_id(auth_data[4]["user_id"]),
)} {offending_key}"""
)} {why.schema.get("enum", "")}"""
return self.finish_json(
400,
{
@ -553,14 +553,14 @@ class ApiServersServerFilesCreateHandler(BaseApiHandler):
try:
validate(data, files_create_schema)
except ValidationError as why:
offending_key = None
if why.get("fill", None):
offending_key = ""
if why.schema.get("fill", None):
offending_key = why.path[0] if why.path else None
err = f"""{self.translator.translate(
err = f"""{offending_key} {self.translator.translate(
"validators",
why.schema.get("error"),
self.controller.users.get_user_lang_by_id(auth_data[4]["user_id"]),
)} {offending_key}"""
)} {why.schema.get("enum", "")}"""
return self.finish_json(
400,
{
@ -628,14 +628,14 @@ class ApiServersServerFilesZipHandler(BaseApiHandler):
try:
validate(data, files_unzip_schema)
except ValidationError as why:
offending_key = None
if why.get("fill", None):
offending_key = ""
if why.schema.get("fill", None):
offending_key = why.path[0] if why.path else None
err = f"""{self.translator.translate(
err = f"""{offending_key} {self.translator.translate(
"validators",
why.schema.get("error"),
self.controller.users.get_user_lang_by_id(auth_data[4]["user_id"]),
)} {offending_key}"""
)} {why.schema.get("enum", "")}"""
return self.finish_json(
400,
{

View File

@ -214,14 +214,14 @@ class ApiServersServerIndexHandler(BaseApiHandler):
else:
validate(data, basic_server_patch_schema)
except ValidationError as why:
offending_key = None
if why.get("fill", None):
offending_key = ""
if why.schema.get("fill", None):
offending_key = why.path[0] if why.path else None
err = f"""{self.translator.translate(
err = f"""{offending_key} {self.translator.translate(
"validators",
why.schema.get("error"),
self.controller.users.get_user_lang_by_id(auth_data[4]["user_id"]),
)} {offending_key}"""
)} {why.schema.get("enum", "")}"""
return self.finish_json(
400,
{

View File

@ -100,14 +100,14 @@ class ApiServersServerWebhooksIndexHandler(BaseApiHandler):
try:
validate(data, new_webhook_schema)
except ValidationError as why:
offending_key = None
if why.get("fill", None):
offending_key = ""
if why.schema.get("fill", None):
offending_key = why.path[0] if why.path else None
err = f"""{self.translator.translate(
err = f"""{offending_key} {self.translator.translate(
"validators",
why.schema.get("error"),
self.controller.users.get_user_lang_by_id(auth_data[4]["user_id"]),
)} {offending_key}"""
)} {why.schema.get("enum", "")}"""
return self.finish_json(
400,
{

View File

@ -138,14 +138,14 @@ class ApiServersServerWebhooksManagementIndexHandler(BaseApiHandler):
try:
validate(data, webhook_patch_schema)
except ValidationError as why:
offending_key = None
if why.get("fill", None):
offending_key = ""
if why.schema.get("fill", None):
offending_key = why.path[0] if why.path else None
err = f"""{self.translator.translate(
err = f"""{offending_key} {self.translator.translate(
"validators",
why.schema.get("error"),
self.controller.users.get_user_lang_by_id(auth_data[4]["user_id"]),
)} {offending_key}"""
)} {why.schema.get("enum", "")}"""
return self.finish_json(
400,
{

View File

@ -668,21 +668,22 @@
"uses": "Number of uses allowed (-1==No Limit)"
},
"validators": {
"filesPageLen": "Length must be greater than 1 for property for prop",
"enumErr": "failed validating. Acceptable data includes: ",
"filesPageLen": "length must be greater than 1 for property",
"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",
"serverAPI": "Invalid Input detected. Please see API docs for information on ",
"serverCreateName": "Server name must be a string with a minimum length of 2 and must not include: \\ / or # ",
"serverExeCommand": "Server execution command must be a string with a minimum length of 1.",
"serverLogPath": "Server log path must be a string with a minimum length of 1",
"typeBool": "Type error: True or False required for ",
"typeInteger": "Type error: Integer required for ",
"typeIntMinVal0": "Must be an integer with a minimum value of 0 for prop ",
"typeList": "Type error: List required for ",
"typeString": "Type error: String required for "
"taskIntervalType": "Task Interval Type must be one of the following: ",
"typeBool": "Type error: True or False required",
"typeInteger": "Type error: Integer required",
"typeIntMinVal0": "must be an integer with a minimum value of 0",
"typeList": "Type error: List required ",
"typeString": "Type error: String required"
},
"webhooks": {
"areYouSureDel": "Are you sure you want to delete this webhook?",