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
transform keyword, is not working with 'toLowerCase' after updating to v3.4.0 #91
Comments
It's difficult to say what you do wrong without a code sample. If you follow docs and code in tests it will work. |
@epoberezkin , thanks for your answer, I discover that this problem is caused by updating the 'ajv' package, using version 6.9.0 or above, were there changes to add this kind of packages? here an example const Ajv = require('ajv');
const ajv = new Ajv({
allErrors: true,
removeAdditional: 'all',
useDefaults: true,
coerceTypes: true
});
require('ajv-keywords')(ajv, 'transform');
const schema = {
"$schema": "http://json-schema.org/draft-07/schema",
"title": "Transform Example",
"description": "The transform keywork doesnt transform object",
"type": "object",
"properties": {
"email": {
"type": "string",
"description": "User email",
"minLength": 5,
"transform": ["trim", "toLowerCase"]
},
"password": {
"type": "string",
"description": "User password",
"minLength": 1
}
},
"required": [
"email",
"password"
]
};
ajv.addSchema(schema, 'login')
const data = {
email: "carloS ",
password: "secret"
};
test(data);
console.log(data);
function test(data) {
var valid = ajv.validate('login', data);
if (valid) console.log('Valid!');
else console.log(ajv.errors);
} Regards |
https://runkit.com/esp/5c6f2ba63c877f00138ea8e2 The culprit seems to be removeAdditional option, and it indeed starts to happen in 6.9.0 It can be related to ajv-validator/ajv#955 |
definitely Ajv issue fixing it there. |
@epoberezkin, oka, I understand, thank you for support. |
fixed in ajv 6.9.2 |
Nice, I confirm the fix, now it works fine!, thanks. |
Hi, I did the update to 3.4.0, and i´m using transform keyword, with 'toLowerCase', but this doesn´t do the transform.
Is needed to add a new keyword to keep this functionality?, thanks.
The text was updated successfully, but these errors were encountered: