Comments (16)
That's what is there in the link you posted (and that's how you can use it):
{
"type": "object",
"properties": {
"size": {
"type": "number",
"minimum": 4,
"errorMessage": {
"type": "Size must be a number",
"minimum": "Size cannot be less than 4"
}
}
}
}
from ajv-errors.
It wasn't working before. I must have missed something. Thanks!
from ajv-errors.
When a type error occurs, the other errors are triggered too. Is there a better way to show only type error message other than going through the errors list and looking for type errors?
from ajv-errors.
I don't understand. What's the schema/data and what are the messages? When you say "triggered" what exactly do you mean?
from ajv-errors.
If I validate { size: 'abc' }
in the above example, it will return both type and minimum error.
from ajv-errors.
It doesn't for me: https://runkit.com/esp/593d4c73c899fe001280d79c
from ajv-errors.
"minimum" etc. is only validated for numbers, it should not generate any errors if the data is not a number.
from ajv-errors.
My mistake, it seems that my application is converting strings to NaN
.
from ajv-errors.
Should it still trigger both type and minimum errors?
from ajv-errors.
for NaN? Yes, because typeof NaN is "number".
from ajv-errors.
Yes, but why is it generating a type error?
from ajv-errors.
it doesn't for me: https://runkit.com/esp/593d4c73c899fe001280d79c
from ajv-errors.
from ajv-errors.
Thanks for the link to the discussion. I'm testing a lot of different types and the type and minimum error were both generated when "type": "integer"
with { size: NaN }
.
{
"type": "object",
"properties": {
"size": {
"type": "integer",
"minimum": 4,
"errorMessage": {
"type": "Size must be an integer",
"minimum": "Size cannot be less than 4"
}
}
}
}
from ajv-errors.
NaN is not an integer. But minimum applies to it because it is a number.
from ajv-errors.
Ok got it. A bit confusing though.
from ajv-errors.
Related Issues (20)
- Reference Error with relative JSON pointer HOT 1
- Custom error for minLength on array property is not working HOT 1
- Be able to set custom keyword for error messages HOT 1
- Receiving error that a dependency is missing after installing ajv-errors.
- Create different error for each validation per attribute HOT 3
- `JSONSchemaType` + `anyOf` corresponding to union over objects cannot correctly determine missing fields HOT 2
- Getting instancePath when using with ajv-keywords and uniqueItemProperties HOT 1
- errorMessage not being set on array of objects? HOT 1
- Keyword error replacement in nested objects it's not working
- Required Keyword Error Message - Error is raised at incorrect level HOT 3
- Question: use enum values in custom error message
- Not getting custom error message for "pattern" keyword
- Is it possible to define a "dictionary" of common error messages?
- errorMessage is not a standard keyword in the JSON Schema specification, hence linting fails HOT 1
- Is this project still being maintained?
- Not working in browser
- Issue when compiling standalone validator with ajv-errors and errorMessage:{ properties:{ HOT 1
- When using ajv-errors package I get this error "Cannot read property 'allErrors' of undefined" HOT 1
- is it possible to add identifier in error, to classify errors
- Generates invalid functions? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ajv-errors.