Sha256: a0a95c8ce0765dd53a68604bf94285c0ed75e4379793ee9edce33b2711898766

Contents?: true

Size: 904 Bytes

Versions: 8

Compression:

Stored size: 904 Bytes

Contents

Lanes.PropTypes ||= {}

checkerFor = (name, checker, isRequired) ->
    Lanes.PropTypes[name] = checker
    Lanes.PropTypes[name].isRequired = isRequired || (props, propName, componentName) ->
        return new Error("#{propName} must be given") unless props[propName]

checkerFor 'Model', (props, propName, componentName) ->
    val = props[propName]
    if val and (!_.isObject(val) or not Lanes.u.isModel(val))
        return new Error("#{propName} is not a Lanes Model")

checkerFor 'State', (props, propName, componentName) ->
    val = props[propName]
    if val and (!_.isObject(val) or not Lanes.u.isState(val))
        return new Error("#{propName} is not a state object")

checkerFor 'Collection', (props, propName, componentName) ->
    val = props[propName]
    if val and (!_.isObject(val) or not Lanes.u.isCollection(val))
        return new Error("#{propName} is not a Lanes Collection")

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
lanes-0.7.0 client/lanes/react/TypeValidators.coffee
lanes-0.6.1 client/lanes/react/TypeValidators.coffee
lanes-0.6.0 client/lanes/react/TypeValidators.coffee
lanes-0.5.6 client/lanes/react/TypeValidators.coffee
lanes-0.5.5 client/lanes/react/TypeValidators.coffee
lanes-0.5.0 client/lanes/react/TypeValidators.coffee
lanes-0.4.0 client/lanes/react/TypeValidators.coffee
lanes-0.3.0 client/lanes/react/TypeValidators.coffee