Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Oct 14 18:05
    evilstiefel commented #1101
  • Oct 14 17:19
    afwn90cj93201nixr2e1re commented #1100
  • Oct 14 17:19
    afwn90cj93201nixr2e1re commented #1100
  • Oct 14 17:06
    evilebottnawi commented #1100
  • Oct 14 16:56
    afwn90cj93201nixr2e1re commented #1100
  • Oct 14 16:55
    afwn90cj93201nixr2e1re commented #1100
  • Oct 14 16:05
    epoberezkin closed #1101
  • Oct 14 16:05
    epoberezkin commented #1101
  • Oct 14 14:16
    evilstiefel commented #1101
  • Oct 14 14:07
    evilstiefel commented #1101
  • Oct 14 14:07
    evilstiefel commented #1101
  • Oct 14 13:56
    epoberezkin commented #137
  • Oct 14 13:32
    epoberezkin commented #137
  • Oct 14 13:31
    muhabalwan commented #137
  • Oct 14 13:28
    muhabalwan commented #137
  • Oct 14 13:28
    muhabalwan commented #137
  • Oct 14 13:28
    muhabalwan commented #137
  • Oct 14 13:19
    epoberezkin commented #1101
  • Oct 14 13:14
    evilstiefel edited #1101
  • Oct 14 13:13
    evilstiefel labeled #1101
Evgeny Poberezkin
@epoberezkin
Thanks for helping support it by the way
Brian Teague
@B-Teague
Thank you!! (This is my first pull request to the open source community)
Brian Teague
@B-Teague
@epoberezkin Question: How big of a design change would it be to have all keywords execute before any validation takes place? Since custom keywords have the option to mutate the JSON data, would it be better to execute all custom keywords before validating the mutated JSON against the provided schema? While using the "allOf" compound keyword does work, it feels like an unnecessary hack.
Brian Teague
@B-Teague
Nevermind, I realized you may want to mutate the data after validation using keywords as well. Not sure if there is a way to say run this keyword before validation and run this keyword after validation.
Evgeny Poberezkin
@epoberezkin
I thought a lot about controlling execution order outside of the schema and decided against it for several reasons:
  1. In JSON Schema spec the order is irrelevant and the results never depend on it
  1. For spec extensions that depend on the order it’s clearer when it is explicitly defined by the schema rather than by some options
So with allOf you can have any order with any keywords and it’s always visible from the schema, hiding it in option would lead to the same schema producing different results
Brian Teague
@B-Teague
Yes, I definitely prefer using explicit design. Thanks for adding my pull request!
Vaibhav Mehta
@i-break-codes
Hi, I am trying to validate the meta schema via compile, where I've deliberately made a typo like "type": 'string' and when I do ajv.errorsText(), it returns me data.properties['foo'].type should be equal to one of the allowed values, data.properties['foo'].type should be array, data.properties['foo'].type should match some schema in anyOf .... is there any way to return a simple message that the data type you provided is incorrect?
Evgeny Poberezkin
@epoberezkin
Schema is validated as if it were data against meta schema
Given that normally such errors should be caught by tests, they are rare. making these error messages semantic would affect runtime performance
There may be a value in a separate package for better schema validation and assessment, e.g. from performance and security points of view
Vaibhav Mehta
@i-break-codes

yea, cuz in the current state, it's difficult to show the end-user that what exactly went wrong.. in the above, a simple error message like...

data type for the type attribute is incorrect.

this should help, so any plans for having a separate package in place?

Evgeny Poberezkin
@epoberezkin
Nope
There is ajv-errors
Vaibhav Mehta
@i-break-codes
yea, I checked that but it's for custom error messages only.. anyways, thanks for the quick response.. appreciated
Rui Silva
@RuiAlias
Hi! I have a question but first of all, thanks for ajv! Is there a way to get the complete list of properties of a Schema, with $ref and allOf expanded using ajv?
From what I've read in the FAQ, it looks like this is not possible. If that is the case, can you guys recommend some other library for this?
Rui Silva
@RuiAlias
Thanks!
Ntropy
@Ntropy
Hi,
Is it possible to enable some additional logging, diagnostic messages in ajv?
Evgeny Poberezkin
@epoberezkin
What is the objective?
Ben Hutton
@Relequestual
I'm trying to get validation errors. Is there any sense of validation error bubbling upwards? As in, if I do allOf > [{required: a}], I get the error on the required but not the allOf, and I'd like to see both. Anyone know? =]
Matthias Mohr
@m-mohr

Hey all,
is there a way to interfere the validation of each value before it is validated against the (sub-)schema? Potentially as plugin?

Background:
I have a JSON structure that can hold variables, which we defined to be an object with an id and a type, for example: {variable_id: 'password', type: 'string'}. These can be embedded in my JSON files, for example:

{
  process: 'login',
  arguments: {
    username: 'john_doe',
    password: {variable_id: 'password', type: 'string'}
  }
}

In the end the variable for password is replaced with a string value, but I don't know that value yet. So what I'd like to do here is to interfere at the point where the value of password is checked against the schema. Currently it fails of course, because the variable object is not a string, which is expected in the JSON schema. So what I need to do is to check if there's an object with a variable_id property before validating against the original part of the JSON schema. If there's a variable I need to run a custom function that checks whether the variable definition is compatible to the schema (I have code for that) and if it's not a variable, just run the validation as usual. Where do I need to interfere in the ajv code? Any hints on that? I can't change the JSON schemas, these are coming from an external source.

Thanks in advance...

Ntropy
@Ntropy
@epoberezkin to make possible to handle successed subschemas
Evgeny Poberezkin
@epoberezkin
@Relequestual let me know if allErrors option helps?
@m-mohr please check the custom keywords - that’s what they are for I think
@Ntropy I think it may be related to annotation collection tbh... Maybe it’s worth allowing generic hooks or events to the instance. I will think about it - it would be a new feature
Matthias Mohr
@m-mohr
@epoberezkin I'm not sure how this could be achieved with custom keywords. I already use them somewhere else and they work very well there, but in this use case? We don't get to the point where the custom keyword could be checked as it already fails beforehand due to a string being expected, not an object. Or do I miss something here?
Ntropy
@Ntropy
@epoberezkin this feature could be used to simplify schemas: by removing conditional subschemas based on data. It can be used as some kind of preprocessor
Evgeny Poberezkin
@epoberezkin
@m-mohr you can use allOf to control execution order
Matthias Mohr
@m-mohr
@epoberezkin Thanks, but then I need to parse the JSON Schema myself and replace all subschemas with allOf's. If I start to parse/modify JSON it get's messy and I don't have much reason anymore to use ajv. So I don't think that's a reasonable way to go. Isn't there a single place in code where one could apply some pre-processing, e.g. by writing a plugin? I just couldn't figure out where that is...
Mattias Severson
@matsev
Hi all,
I have problem with ajv JSON validation of a JavaScript object that contains line breaks, e.g. { key: 'a string\nwith a line break' }. Consequently, I have posted a question on SO. Please write a line or two if you know what I am doing wrong?
Evgeny Poberezkin
@epoberezkin
  1. You don’t need to serialise data. 2. “.” in regex does not match new line character
Ben Hutton
@Relequestual
Hello. @epoberezkin draft-8 is due to be published any day now. There is at least one implementation which already has a beta for testing. Do you have plans to support draft-8? =]
Evgeny Poberezkin
@epoberezkin
@Relequestual I will ready it!
Read it
@/all any interest to contribute to draft-8 support and generally to Ajv development further?
Evgeny Poberezkin
@epoberezkin
@Relequestual is there change log - everything that was added/changed/removed?
Ben Hutton
@Relequestual
@epoberezkin You'd have to look at each document. There's a changelog at the end, which is in the index
Mahmoud Abd Al Kareem
@MahmoudAbdAlKareem
Hello
I'm trying to use ajv for FHIR schema validation
IS there any resources for that?
ttxndrx
@ttxndrx
When referencing external schemas with $ref, can the compiled schema provide an expanded/evaluated representation, where all references are replaced by the actual schemas?