Use human readable errors for roles schema

This commit is contained in:
amcmanu3
2024-08-06 13:13:11 -04:00
parent 7ae7c0f50d
commit dcd81102fa
3 changed files with 24 additions and 4 deletions

View File

@ -12,25 +12,29 @@ create_role_schema = {
"type": "string",
"minLength": 1,
"pattern": r"^[^,\[\]]*$",
"error": "roleName",
},
"servers": {
"type": "array",
"error": "typeList",
"items": {
"type": "object",
"properties": {
"server_id": {
"type": "string",
"minimum": 1,
"error": "roleServerId",
},
"permissions": {
"type": "string",
"pattern": r"^[01]{8}$", # 8 bits, see EnumPermissionsServer
"error": "roleServerPerms",
},
},
"required": ["server_id", "permissions"],
},
},
"manager": {"type": ["integer", "null"]},
"manager": {"type": ["integer", "null"], "error": "roleManager"},
},
"additionalProperties": False,
"minProperties": 1,
@ -42,19 +46,23 @@ basic_create_role_schema = {
"name": {
"type": "string",
"minLength": 1,
"error": "roleName",
},
"servers": {
"type": "array",
"error": "typeList",
"items": {
"type": "object",
"properties": {
"server_id": {
"type": "string",
"minimum": 1,
"error": "roleServerId",
},
"permissions": {
"type": "string",
"pattern": "^[01]{8}$", # 8 bits, see EnumPermissionsServer
"pattern": r"^[01]{8}$", # 8 bits, see EnumPermissionsServer
"error": "roleServerPerms",
},
},
"required": ["server_id", "permissions"],

View File

@ -11,25 +11,29 @@ modify_role_schema = {
"type": "string",
"minLength": 1,
"pattern": r"^[^,\[\]]*$",
"error": "roleName",
},
"servers": {
"type": "array",
"error": "typeList",
"items": {
"type": "object",
"properties": {
"server_id": {
"type": "string",
"minimum": 1,
"error": "roleServerId",
},
"permissions": {
"type": "string",
"pattern": r"^[01]{8}$", # 8 bits, see EnumPermissionsServer
"error": "roleServerPerms",
},
},
"required": ["server_id", "permissions"],
},
},
"manager": {"type": ["integer", "null"]},
"manager": {"type": ["integer", "null"], "error": "roleManager"},
},
"additionalProperties": False,
"minProperties": 1,
@ -41,19 +45,23 @@ basic_modify_role_schema = {
"name": {
"type": "string",
"minLength": 1,
"error": "roleName",
},
"servers": {
"type": "array",
"error": "typeList",
"items": {
"type": "object",
"properties": {
"server_id": {
"type": "string",
"minimum": 1,
"error": "roleServerId",
},
"permissions": {
"type": "string",
"pattern": "^[01]{8}$", # 8 bits, see EnumPermissionsServer
"pattern": r"^[01]{8}$", # 8 bits, see EnumPermissionsServer
"error": "roleServerPerms",
},
},
"required": ["server_id", "permissions"],

View File

@ -670,6 +670,10 @@
"validators": {
"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",
"typeBool": "Type error: True or False required for ",
"typeInteger": "Type error: Integer required for ",
"typeList": "Type error: List required for ",