Data Caster

Data Caster

  • Docs
  • GitHub

›Rules

General

  • Getting Started

Transformations

  • Basics
  • Phases

API reference

    Initialization

    • init
    • clone

    Rules

    • string
    • number
    • int
    • bool
    • date
    • object
    • array
    • stringArray
    • numberArray
    • intArray
    • boolArray
    • dateArray
    • objectArray
    • any

    Field manipulations

    • exclude
    • include
    • clearExcluded
    • ignoreExcluded

    Processing

    • adapt
    • adaptList
    • revert
    • revertList

bool

Adds description for Boolean field in DataCaster instance.

This method is chainable.

Signature

bool(originName, options = {})

options is an object that can be omitted. To get more about options see Fields section

Example

import { DataCaster } from '@daminort/data-caster';

const dc = new DataCaster()
  .int('id')
  .string('name')
  .bool('is_active');
    
const result = dc.adapt(serverObject);
// before
{
  id: 1,
  name: 'John Snow',
  is_active: 1,
}

// after
{
  id: 1,
  name: 'John Snow',
  isActive: true,
}
← intdate →
  • Signature
  • Example
Data Caster
Docs
Getting StartedBasicsAPI Reference
More
GitHubFacebook Open Source
Copyright © 2019 Demien