Skip to content

Instantly share code, notes, and snippets.

@goellner
Last active December 12, 2022 21:44
Show Gist options
  • Save goellner/674d9bc91f4e95c0560c5db683caae0e to your computer and use it in GitHub Desktop.
Save goellner/674d9bc91f4e95c0560c5db683caae0e to your computer and use it in GitHub Desktop.
JSON validation for laravel-translatable column
ALTER TABLE user
ADD CONSTRAINT attributes_are_valid check(
JSON_SCHEMA_VALID('{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"patternProperties" : {
"^[a-z][a-z]$": {
"type": "string"
}
},
"minProperties": 1,
"additionalProperties": false
}', slug
)
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment