Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
R
rjs_json_form
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Jérome Perrin
rjs_json_form
Commits
cb7128e7
Commit
cb7128e7
authored
Aug 31, 2018
by
Boris Kocherov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tv4: add const support
parent
07dd0ad7
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
0 deletions
+13
-0
jsonform/tv4.js
jsonform/tv4.js
+13
-0
No files found.
jsonform/tv4.js
View file @
cb7128e7
...
@@ -725,6 +725,9 @@ ValidatorContext.prototype.validateBasic = function validateBasic(data, schema,
...
@@ -725,6 +725,9 @@ ValidatorContext.prototype.validateBasic = function validateBasic(data, schema,
if
(
error
=
this
.
validateType
(
data
,
schema
,
dataPointerPath
))
{
if
(
error
=
this
.
validateType
(
data
,
schema
,
dataPointerPath
))
{
return
error
.
prefixWith
(
null
,
"
type
"
);
return
error
.
prefixWith
(
null
,
"
type
"
);
}
}
if
(
error
=
this
.
validateConst
(
data
,
schema
,
dataPointerPath
))
{
return
error
.
prefixWith
(
null
,
"
const
"
);
}
if
(
error
=
this
.
validateEnum
(
data
,
schema
,
dataPointerPath
))
{
if
(
error
=
this
.
validateEnum
(
data
,
schema
,
dataPointerPath
))
{
return
error
.
prefixWith
(
null
,
"
type
"
);
return
error
.
prefixWith
(
null
,
"
type
"
);
}
}
...
@@ -755,6 +758,14 @@ ValidatorContext.prototype.validateType = function validateType(data, schema) {
...
@@ -755,6 +758,14 @@ ValidatorContext.prototype.validateType = function validateType(data, schema) {
return
this
.
createError
(
ErrorCodes
.
INVALID_TYPE
,
{
type
:
dataType
,
expected
:
allowedTypes
.
join
(
"
/
"
)},
''
,
''
,
null
,
data
,
schema
);
return
this
.
createError
(
ErrorCodes
.
INVALID_TYPE
,
{
type
:
dataType
,
expected
:
allowedTypes
.
join
(
"
/
"
)},
''
,
''
,
null
,
data
,
schema
);
};
};
ValidatorContext
.
prototype
.
validateConst
=
function
validateConst
(
data
,
schema
)
{
if
(
schema
.
const
===
undefined
||
recursiveCompare
(
data
,
schema
.
const
))
{
return
null
;
}
return
this
.
createError
(
ErrorCodes
.
CONST_NOT_EQUAL
,
{},
''
,
''
,
null
,
data
,
schema
);
};
ValidatorContext
.
prototype
.
validateEnum
=
function
validateEnum
(
data
,
schema
)
{
ValidatorContext
.
prototype
.
validateEnum
=
function
validateEnum
(
data
,
schema
)
{
if
(
schema
[
"
enum
"
]
===
undefined
)
{
if
(
schema
[
"
enum
"
]
===
undefined
)
{
return
null
;
return
null
;
...
@@ -1379,6 +1390,7 @@ var ErrorCodes = {
...
@@ -1379,6 +1390,7 @@ var ErrorCodes = {
ONE_OF_MULTIPLE
:
12
,
ONE_OF_MULTIPLE
:
12
,
NOT_PASSED
:
13
,
NOT_PASSED
:
13
,
BOOLEAN_SCHEMA_FALSE
:
14
,
BOOLEAN_SCHEMA_FALSE
:
14
,
CONST_NOT_EQUAL
:
15
,
// Numeric errors
// Numeric errors
NUMBER_MULTIPLE_OF
:
100
,
NUMBER_MULTIPLE_OF
:
100
,
NUMBER_MINIMUM
:
101
,
NUMBER_MINIMUM
:
101
,
...
@@ -1421,6 +1433,7 @@ var ErrorMessagesDefault = {
...
@@ -1421,6 +1433,7 @@ var ErrorMessagesDefault = {
ONE_OF_MULTIPLE
:
"
Data is valid against more than one schema from
\"
oneOf
\"
: indices {index1} and {index2}
"
,
ONE_OF_MULTIPLE
:
"
Data is valid against more than one schema from
\"
oneOf
\"
: indices {index1} and {index2}
"
,
NOT_PASSED
:
"
Data matches schema from
\"
not
\"
"
,
NOT_PASSED
:
"
Data matches schema from
\"
not
\"
"
,
BOOLEAN_SCHEMA_FALSE
:
"
Schema does not allow any data
"
,
BOOLEAN_SCHEMA_FALSE
:
"
Schema does not allow any data
"
,
CONST_NOT_EQUAL
:
"
Data does not match schema.const
"
,
// Numeric errors
// Numeric errors
NUMBER_MULTIPLE_OF
:
"
Value {value} is not a multiple of {multipleOf}
"
,
NUMBER_MULTIPLE_OF
:
"
Value {value} is not a multiple of {multipleOf}
"
,
NUMBER_MINIMUM
:
"
Value {value} is less than minimum {minimum}
"
,
NUMBER_MINIMUM
:
"
Value {value} is less than minimum {minimum}
"
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment