-
Notifications
You must be signed in to change notification settings - Fork 89
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
Common Hooks validateschema error #229
Comments
|
Ok - I'll dig into it deeper. I reported that I added |
I'm having the same issue. I solved the error message by updating the schema version in my JSON Schema but I still cannot get validation to happen. change from v04 Per the upgrade to AJV 5.0.0 |
|
Right, the hook does not work for two reasons. First is the schema 04 to 06 change needed and second is validation succeeds all the time. I managed to fix by rewriting my own and I intend to debug the common hook to see why it is not working.
|
This hooks is being used in production so I look forward to what you find. Thanks! |
This has been consolidated with #372 |
Steps to reproduce
https://docs.feathersjs.com/api/hooks-common.html#validateschema fresh install inserted in CREATE user-hooks.js validate schema as per the link above.
module.exports = {
before: {
all: [],
find: [ authenticate('jwt') ],
get: [ ...restrict ],
create: [ validateSchema(userSchema(), Ajv), hashPassword(), setCreatedAt(), setUpdatedAt()
],update: [ ...restrict, hashPassword() ],
patch: [ ...restrict, hashPassword() ],
remove: [ ...restrict ]
},
function userSchema() { return { title: 'User Schema', $schema: 'http://json-schema.org/draft-04/schema#', type: 'object', required: [ 'email', 'password', 'role' ], additionalProperties: false, properties: { email: { type: 'string', maxLength: 100, minLength: 6 }, password: { type: 'string', maxLength: 30, minLength: 8 }, role: { type: 'string' } } }; }
ERROR
/Users/me/Develop/feathers/src/services/users/users.hooks.js:22 create: [ validateSchema(userSchema(), Ajv), hashPassword(), setCreatedAt(), setUpdatedAt() ], ReferenceError: Ajv is not defined
I added
const Ajv = require('ajv');
New error:
`
/Users/Tektango/Develop/feathers/node_modules/ajv/lib/ajv.js:94
if (!v) throw new Error('no schema with key or ref "' + schemaKeyRef + '"');
Error: no schema with key or ref "http://json-schema.org/draft-04/schema#"
`
https://github.com/epoberezkin/ajv says
The text was updated successfully, but these errors were encountered: