We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Hello I was following the examples to validate against a date range
{ "definitions": {}, "$schema": "http://json-schema.org/draft-07/schema#", "$id": "https://some-url/mini-schema.json", "type": "object", "title": "Mini Schema", "required": [ "year" ], "additionalProperties": false, "properties": { "year": { "$id": "#/properties/year", "type": "string", "title": "Year (4 digits)", "description": "a valid year string in YYYY format", "default": "", "moment": { "format": [ "YYYY" ], "validate": [ { "test": "isSameOrAfter", "value": "1900-01-01T00:00:00.000Z" }, { "test": "isSameOrBefore", "value": "2999-01-01T00:00:00.000Z" } ] }, "examples": [ "2020" ] } } }
{ year: '2010' }
data/year "isAfter" validation failed for value(s): null
"ajv": "^6.10.2", "ajv-keywords": "^3.4.1", "ajv-moment": "^2.0.3", "moment": "^2.24.0", "moment-timezone": "^0.5.27"
I think the problem is at this line of code https://github.com/cludden/ajv-moment/blob/master/lib/index.js#L82
const _val = { now: val.now, $data: val.$data, manipulate: val.manipulate }; if (_val.now !== true && typeof _val.$data === 'string') { _val.value = it.util.getData(_val.$data, it.dataLevel, it.dataPathArr); }
_val.value is always undefined when "value" is a constant like in my example
_val.value
undefined
Should be
const _val = { now: val.now, $data: val.$data, manipulate: val.manipulate }; if (typeof val === 'string'){ _val.value = JSON.stringify(val); } else if (_val.now !== true && typeof _val.$data === 'string') { _val.value = it.util.getData(_val.$data, it.dataLevel, it.dataPathArr); }
I will try to submit a PR
The text was updated successfully, but these errors were encountered:
fd227d5
Merge pull request #14 from lamuertepeluda/constant-values-validation
4572ab1
fix #13
No branches or pull requests
Hello I was following the examples to validate against a date range
Schema
Data
Error text
Library Versions
I think the problem is at this line of code https://github.com/cludden/ajv-moment/blob/master/lib/index.js#L82
_val.value
is alwaysundefined
when "value" is a constant like in my exampleShould be
I will try to submit a PR
The text was updated successfully, but these errors were encountered: