-
-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
minor(vest): support schema skip and only (#557)
- Loading branch information
Showing
14 changed files
with
589 additions
and
30 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
62 changes: 62 additions & 0 deletions
62
packages/n4s/src/meta/__tests__/__snapshots__/ruleMeta.test.js.snap
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
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 |
---|---|---|
@@ -1,4 +1,6 @@ | ||
|
||
import message from 'ruleMessage'; | ||
import warn from 'ruleWarn'; | ||
import when from 'ruleWhen'; | ||
|
||
export default { warn, message }; | ||
export default { warn, message, when }; |
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,13 @@ | ||
import EnforceContext from 'EnforceContext'; | ||
import optionalFunctionValue from 'optionalFunctionValue'; | ||
|
||
export default function when(value, condition, bail) { | ||
const shouldBail = !optionalFunctionValue( | ||
condition, | ||
[EnforceContext.unwrap(value)].concat( | ||
EnforceContext.is(value) ? [value.key, value.obj] : [] | ||
) | ||
); | ||
|
||
return bail(shouldBail); | ||
} |
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,23 +1,26 @@ | ||
declare function getFn(fieldName: string): string[]; | ||
declare function getFn(): { [fieldName: string]: string[] }; | ||
|
||
declare function schema( | ||
enforceSchema: any | ||
): ( | ||
data: any | ||
) => { | ||
hasErrors: (fieldName?: string) => boolean; | ||
hasWarnings: (fieldName?: string) => boolean; | ||
getErrors: typeof getFn; | ||
getWarnings: typeof getFn; | ||
tests: { | ||
[key: string]: { | ||
hasErrors: boolean; | ||
hasWarnings: boolean; | ||
warnings: string[]; | ||
errors: string[]; | ||
interface schema { | ||
(enforceSchema: any, body?: (...args: any[]) => void): ( | ||
data: any | ||
) => { | ||
hasErrors: (fieldName?: string) => boolean; | ||
hasWarnings: (fieldName?: string) => boolean; | ||
getErrors: typeof getFn; | ||
getWarnings: typeof getFn; | ||
tests: { | ||
[key: string]: { | ||
hasErrors: boolean; | ||
hasWarnings: boolean; | ||
warnings: string[]; | ||
errors: string[]; | ||
}; | ||
}; | ||
}; | ||
}; | ||
|
||
skip: (namespace: string) => void; | ||
only: (namespace: string) => void; | ||
} | ||
|
||
export default schema; |
Oops, something went wrong.