Last active
July 22, 2020 16:18
-
-
Save thenamankumar/a266faab167f29320438204515864a71 to your computer and use it in GitHub Desktop.
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
const Rules: RulesType = require('./rules.json'); | |
export type RuleName = string; | |
interface BaseRule { | |
butNot?: RuleDefinition; | |
optional?: boolean; | |
} | |
export interface OfValueRule extends BaseRule { | |
ofValue: string; | |
} | |
export interface OfPatternRule extends BaseRule { | |
ofPattern: string; | |
} | |
export interface PunctuatorRule extends BaseRule { | |
punctuator: string; | |
} | |
export interface KeywordRule extends BaseRule { | |
keyword: string; | |
} | |
export interface OneOfRule extends BaseRule { | |
oneOf: string[]; | |
} | |
export interface OfTypeRule extends BaseRule { | |
ofType: RuleDefinition; | |
} | |
export interface OneOfTypeRule extends BaseRule { | |
oneOfType: [RuleDefinition]; | |
} | |
export interface ListOfTypeRule extends BaseRule { | |
listOfType: RuleDefinition; | |
} | |
export type RuleDefinition = | |
| RuleName | |
| OfValueRule | |
| OfPatternRule | |
| PunctuatorRule | |
| KeywordRule | |
| OneOfRule | |
| OfTypeRule | |
| OneOfTypeRule | |
| ListOfTypeRule | |
| [RuleDefinition]; | |
export interface RulesType { | |
[ruleDefinitionName: RuleName]: RuleDefinition; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment