-
-
Notifications
You must be signed in to change notification settings - Fork 873
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Custom keyword modifying data doesn't run during parsing #1952
Comments
I believe your schema should be as follows (without the {
elements: {
properties: {
amount: <any>{
type: "string",
parseDecimal: true,
},
},
additionalProperties: true,
},
}; |
Forgot to say, this is a JTD schema not a JSON Schema, so extra keywords are only allowed under the |
Hi, Is there any update on this one? Regards. |
Sorry for the delay. Keywords that modify data have to be explicitly marked as such (modifying: true), otherwise they won't update the object with the data, they would simply update the local variable. See this doc: https://ajv.js.org/api.html#ajv-addkeyword-definition-object-ajv |
although, you are explicitly updating parent data... |
Hi, Thanks for the reply.
I'm only doing that in this case because I want to replace the value of Regards, |
Hi, I'm trying to parse to a custom type, but running into some issues.
What version of Ajv are you using? Does the issue happen if you use the latest version?
"ajv": "^8.11.0"
Ajv options object
JSON Schema
Sample data
What results did you expect?
Based on the examples in #141 I expect to have the value of amount parsed to a BigNumber object if successful, but it seems like it's still a string.
Btw, it seems like I also have to cast the property object in schema to to satisfy the type checking even though I will be coercing the value from
string
toBigNumber
. Is there a plan to address this limitation / support this use case?Are you going to resolve the issue?
If there is a more appropriate way to do this, I'm happy to. Right now I have to work around it by using validate() instead of parse() directly.
The text was updated successfully, but these errors were encountered: