Stuart Clark (Deciphered): Vale 1.0.0; prose linting for Drupal

meta.vale on a 201, with a warning
{
"errors": [
{
"title": "Unprocessable Content",
"status": "422",
"detail": "body.0.value: Body: Vale.Repetition: 'the' is repeated! (line 1: "the the")",
"source": {
"pointer": "/data/attributes/body/value"
}
}
]
}
POST /jsonapi/node/article, with “Check the the docs.” in the body
This is the part I built it for. On a Fully Decoupled site, a Druxt or Nuxt frontend writes over JSON:API, and the check runs in the entity’s validation, which those writes go through as well as the form. Post a body with a repeated word, with Vale’s built-in style on, and you get a 422 that points at the field:{
"meta": {
"vale": {
"checked": true,
"alerts": [
{
"entity_type": "node",
"bundle": "article",
"id": "a22048fc-b0ec-4a9b-a80b-14be85498d81",
"field": "body",
"delta": 0,
"rule": "Microsoft.Adverbs",
"level": "warning",
"message": "Remove 'very' if it's not important to the meaning of the statement.",
"line": 1,
"start": 9,
"end": 12,
"match": "very",
"description": "",
"link": "https://learn.microsoft.com/en-us/style-guide/word-choice/use-simple-words-concise-sentences"
}
]
}
}
}

So a Fully Decoupled editor gets the same feedback as the node form, without rebuilding the rules in JavaScript.

Similar Posts