Skip to content

Latest commit

 

History

History
34 lines (28 loc) · 639 Bytes

Validators.md

File metadata and controls

34 lines (28 loc) · 639 Bytes

Validators

For every AST node, the bredon-types package ships a validator function that simply checks the node type.

The following validators exist:

  • isDimension
  • isExpression
  • isFloat
  • isFunctionExpression
  • isHexColor
  • isIdentifier
  • isInteger
  • isOperator
  • isParenthesis
  • isSeparator
  • isStringLiteral
  • isUrl
  • isValue
  • isValueList

Each validator function takes a single AST node as first parameter and returns a boolean.

Example

import { isIdentifier, isHexColor } from 'bredon-types'

const ast = {
  type: 'HexColor',
  value: 'FFF'  
}

isIdentifier(ast) // => false
isHexColor(ast) // => true