ajv-validator / ajv-validator/ajv-errors

Custom error messages for patternProperties

Offen
#35 1 Kommentar 1 Reaktion 0 zugewiesene Personen Auf GitHub ansehen
enhancement
Vorherrschende Sprache
TypeScript
Sterne
289
Forks
21
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

Is there any way where one can add custom error message for pathPattern attributes? Example:

Json schema:
```javascript
"patternProperties": {
"^[a-zA-Z0-9]*$":{
"properties": {
"model":{"type":"string"},
"made":{"type":"string"},
"year":{"type":"string"}
}
}
},
"additionalProperties":false
}
```
Json:
```javascript
{
"efgh56789": {
"model": "civic"
"made": "toyota"
"year": "2014"
}
}
```
Here, how to add custom error message (ex: Can contain only alphanumeric characters) for the attribute 'efgh56789' in above schema?
Note: The schema can be a nested schema where few of them are 'patternProperties' & few of them are regular ones.

I have asked the same question in SoF:
Ref: [link](https://stackoverflow.com/questions/59478158/using-custom-error-message-for-patternproperties-attribute-using-ajv-error-npm-m)

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.