-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for validating functions inside schema's rules (#2151)
* Add specs, defaults, and documentation to next/previous rule properties * Add comparator function support for kind/object, type, data, and mark
- Loading branch information
1 parent
6369d05
commit 405cef0
Showing
26 changed files
with
872 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
packages/slate/test/schema/custom/child-kind-invalid-function.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/** @jsx h */ | ||
|
||
import h from '../../helpers/h' | ||
|
||
export const schema = { | ||
blocks: { | ||
paragraph: {}, | ||
quote: { | ||
nodes: [ | ||
{ | ||
match: [{ object: o => ['inline', 'text'].includes(o) }], | ||
}, | ||
], | ||
}, | ||
}, | ||
} | ||
|
||
export const input = ( | ||
<value> | ||
<document> | ||
<quote> | ||
<paragraph>text</paragraph> | ||
</quote> | ||
</document> | ||
</value> | ||
) | ||
|
||
export const output = ( | ||
<value> | ||
<document> | ||
<quote /> | ||
</document> | ||
</value> | ||
) |
32 changes: 32 additions & 0 deletions
32
packages/slate/test/schema/custom/child-type-invalid-function.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/** @jsx h */ | ||
|
||
import h from '../../helpers/h' | ||
|
||
export const schema = { | ||
blocks: { | ||
paragraph: {}, | ||
quote: { | ||
nodes: [ | ||
{ | ||
match: [{ type: t => t === 'paragraph' }], | ||
}, | ||
], | ||
}, | ||
}, | ||
} | ||
|
||
export const input = ( | ||
<value> | ||
<document> | ||
<quote> | ||
<image /> | ||
</quote> | ||
</document> | ||
</value> | ||
) | ||
|
||
export const output = ( | ||
<value> | ||
<document /> | ||
</value> | ||
) |
30 changes: 30 additions & 0 deletions
30
packages/slate/test/schema/custom/first-child-kind-invalid-function.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/** @jsx h */ | ||
|
||
import h from '../../helpers/h' | ||
|
||
export const schema = { | ||
blocks: { | ||
paragraph: {}, | ||
quote: { | ||
first: [{ object: o => o === 'text' }], | ||
}, | ||
}, | ||
} | ||
|
||
export const input = ( | ||
<value> | ||
<document> | ||
<quote> | ||
<paragraph /> | ||
</quote> | ||
</document> | ||
</value> | ||
) | ||
|
||
export const output = ( | ||
<value> | ||
<document> | ||
<quote /> | ||
</document> | ||
</value> | ||
) |
35 changes: 35 additions & 0 deletions
35
packages/slate/test/schema/custom/first-child-type-invalid-function.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/** @jsx h */ | ||
|
||
import h from '../../helpers/h' | ||
|
||
export const schema = { | ||
blocks: { | ||
paragraph: {}, | ||
quote: { | ||
first: { type: t => t === 'paragraph' }, | ||
}, | ||
}, | ||
} | ||
|
||
export const input = ( | ||
<value> | ||
<document> | ||
<quote> | ||
<image /> | ||
<paragraph /> | ||
<paragraph /> | ||
</quote> | ||
</document> | ||
</value> | ||
) | ||
|
||
export const output = ( | ||
<value> | ||
<document> | ||
<quote> | ||
<paragraph /> | ||
<paragraph /> | ||
</quote> | ||
</document> | ||
</value> | ||
) |
30 changes: 30 additions & 0 deletions
30
packages/slate/test/schema/custom/last-child-kind-invalid-function.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/** @jsx h */ | ||
|
||
import h from '../../helpers/h' | ||
|
||
export const schema = { | ||
blocks: { | ||
paragraph: {}, | ||
quote: { | ||
last: [{ object: o => o === 'text' }], | ||
}, | ||
}, | ||
} | ||
|
||
export const input = ( | ||
<value> | ||
<document> | ||
<quote> | ||
<paragraph /> | ||
</quote> | ||
</document> | ||
</value> | ||
) | ||
|
||
export const output = ( | ||
<value> | ||
<document> | ||
<quote /> | ||
</document> | ||
</value> | ||
) |
35 changes: 35 additions & 0 deletions
35
packages/slate/test/schema/custom/last-child-type-invalid-function.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/** @jsx h */ | ||
|
||
import h from '../../helpers/h' | ||
|
||
export const schema = { | ||
blocks: { | ||
paragraph: {}, | ||
quote: { | ||
last: { type: t => t === 'paragraph' }, | ||
}, | ||
}, | ||
} | ||
|
||
export const input = ( | ||
<value> | ||
<document> | ||
<quote> | ||
<paragraph /> | ||
<paragraph /> | ||
<image /> | ||
</quote> | ||
</document> | ||
</value> | ||
) | ||
|
||
export const output = ( | ||
<value> | ||
<document> | ||
<quote> | ||
<paragraph /> | ||
<paragraph /> | ||
</quote> | ||
</document> | ||
</value> | ||
) |
Oops, something went wrong.