Skip to main content

how to exclude certain values for a string property in ajv schema?

  name: {
    type: "string",
    minLength: 1,
    maxLength: 15,
    pattern: "^[^\\s].+[^\\s]$", // blocks leading and trailing white spaces
    errorMessage: "name",
  },

The above is the ajv schema for the name property. How do I further specify that certain values are not allowed. For example, "Hitler" and "Khan" are not allowed.

Via Active questions tagged javascript - Stack Overflow https://ift.tt/yqjL4VK

Comments