-
-
Notifications
You must be signed in to change notification settings - Fork 127
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
Defaults not applied from schema #85
Comments
I'm not really sure what the problem is. We tell Line 85 in 931ffce
|
@issuehunt has funded $40.00 to this issue.
|
@YodaDaCoda I cannot reproduce the case with basic type( About use const Ajv = require('ajv');
const ajv = new Ajv({
allErrors: true,
format: 'full',
useDefaults: true,
errorDataPath: 'property'
});
const schema = {
type: "object",
properties: {
fizz: {
type: "object",
properties: {
bar: {
type: 'string',
default: 'baz',
},
},
},
},
};
const data = {};
var validate = ajv.compile(schema);
console.log(validate(data)); // true
console.log(data); // { } The best we can do is document this in readme. |
@yaodingyd thanks, this has made me review my issue. This is interesting. Adding From what I can tell, draft 07 of the spec doesn't define the behaviour of a validator in this regard. Draft 08 adds some examples that happen to include handling of defaults, and seems to imply that the results I expected are correct (i.e. able to specify defaults on a sub-property without specifying that the property is This sounds like an |
Isn't |
@krnik true. I think @YodaDaCoda is right in his expectation. When there is
At least the work around is easy, haha. Yup, sounds like problem in |
Can you open an issue on |
I'm having similar problem, not sure if it's related. I've had:
Which worked fine, correct default value gets created. Once I added another value to schema, it is not being added when I run the app again:
Am I doing something wrong or? I don't have Interestingly, if I remove my store file, on the app restart only the first So then I tried: put note: just noticed that this is for |
hey @sindresorhus I think this is indeed the bug in I've been playing with some workarounds here and elsewhere (where they check if This seems to do the trick to save the file:
I think that we need to save every time? not familiar with the code to say where the fix should go
|
This issue should be closed, as this library is using |
I'm using a schema to create my settings, and I've been unable to have
conf
orelectron-config
use the defaults provided in the schema.I've included a reduced test case here:
An rough solution to populate defaults from schema is below, but I wouldn't expect to have to do this when using a schema that includes defaults.
IssueHunt Summary
Backers (Total: $40.00)
Become a backer now!
Or submit a pull request to get the deposits!
Tips
IssueHunt has been backed by the following sponsors. Become a sponsor
The text was updated successfully, but these errors were encountered: