November's Paddleball Marathon

    weex-style-validator

    0.1.0 • Public • Published

    Weex Style Validator

    Check if weex components support the specific styles.

    API

    • configure: [Function] config the validator
    • validateStyles: [Function] validate component styles

    Usage

    Validate styles

    const validator = require('weex-style-validator')
     
    /**
     * Validate style object.
     * @param {Object} style map
     */
    validator.validateStyles(styles)
     
    /**
     * Validate styles for specific component.
     * @param {String} componentName 
     * @param {Object} style map
     */
    validator.validateStyles(componentName, styles)

    Config the validator

    const validator = require('weex-style-validator')
     
    /**
     * Config the validator.
     * @param {Object} configure 
     */
    validator.configure({
      // Whether to suppress the warnings in the console.
      // Default is false, will print warnings in the console by default.
      silent: true,
     
      // Executed when an illegal style is encountered
      onfail: function (message) {
        // do something ...
      }
    })

    Common Error Output

    Weex use display: flex; by default:

    [Style Validator] Not support to use the "display" style property.
    

    Weex doesn't support short-hand properties currently:

    [Style Validator] Not support to use the "margin" style property.
    [Style Validator] Not support to use the "border" style property.
    [Style Validator] <div> is not support to use the "margin" style property.
    [Style Validator] <image> is not support to use the "padding" style property.
    

    Install

    npm i weex-style-validator

    DownloadsWeekly Downloads

    3

    Version

    0.1.0

    License

    Apache-2.0

    Last publish

    Collaborators

    • fkysly
    • hanks
    • mr.raindrop