Skip to main content

Values

A field takes an ordinary JavaScript value, and dari converts it to what the field holds, checking it on the way. This page is what each kind of field accepts, and the classes for the values JavaScript has no type of its own for: a location, an area, a file, and the dates and times. Each class is listed with its signature in the dari reference.

What each field accepts​

The field holdsGive itNotes
TextA string, or any value, which is converted to textA field with a fixed set of values refuses anything outside it, naming the values it takes.
A numberA number, or text that reads as one
True or falsetrue; anything else is stored as false
A date or instantA Date, epoch milliseconds, or ISO textStored as epoch milliseconds.
An idA UUID string, or a Record or RecordRef, whose id is taken
A URL or URIA string
A locationA Location, or an object with latitude and longitudeSee Locations and areas.
An areaA Region, or one in its stored formSee Locations and areas.
A fileA StorageItem, a URL as a string, or a stored itemSee Files.
A list or setAn array, each item converted as the item's kind
A mapAn object, each value converted as the value's kind
An embedded objectA RecordSee Embedded objects and references.
A referenceA RecordRef, or the content's id
A date or time of one of the kinds belowA Date, text in the stored form, or the matching classSee Dates and times.
Rich textA RichText, or markup as a stringSee Rich text.

null clears a field. undefined is refused, since it usually means a misspelled variable:

1
Field "headline" was given undefined; use null to clear it.

A field of a kind this SDK does not write fails naming the kind, and putRaw(name, value) writes its stored form directly if you know it.

Locations and areas​

1
const { Location, Region } = dari;
2
3
venue.put("where", new Location(39.1498124, -76.848583));
4
5
venue.put("deliveryArea", Region.circle(new Location(39.0, -76.0), 5000));

Location takes a latitude and a longitude, in that order. Region.circle takes a centre and a radius in metres; Region.polygon takes a list of locations, and closes the shape for you. Add more than one with addCircle and addPolygon.

Reading an area back gives you centres and metres rather than the stored form:

1
const area = Region.fromState(venue.get("deliveryArea"));
2
3
area.circleList[0].radiusInMeters; // 5000

Files​

A script has no network access, so it cannot upload. It can point a file field at something the CMS can already reach:

1
const { StorageItem } = dari;
2
3
article.put("leadImage", StorageItem.url(payload.cdnUrl)
4
.withContentType("image/png")
5
.withMetadata({ width: 800, height: 600 }));

A plain URL works as shorthand:

1
article.put("leadImage", "https://cdn.example.com/pic.png");

To copy a file from one asset to another, read it and set it:

1
target.put("leadImage", StorageItem.fromState(source.get("leadImage")));

Dates and times​

Brightspot stores a moment in several different ways: an exact instant, a calendar date with no time, a time of day with no date, and more. A JavaScript Date works for all of them, because the field says which one it is:

1
const when = new Date("2026-08-14T01:15:30Z");
2
3
article.putAll({
4
publishedOn: when, // an exact instant
5
runsOn: when, // a calendar date
6
startsAt: when, // a time of day
7
airsAt: when // a date and time with a zone
8
});

Choose the time zone​

A calendar date depends on where you are. The instant above is 14 August in UTC and 13 August in New York.

warning

dari.timeZone defaults to UTC. Set it to the zone your dates belong to before you convert any, or an evening's content lands on the wrong day:

1
dari.timeZone = "America/New_York";

It applies to every conversion from a Date in the script. A name the runtime doesn't know is refused on the spot.

Building values directly​

Where you have parts rather than a moment, or a length of time rather than a point in one, build the value:

1
const { LocalDate, LocalTime, Year, Duration, Period } = dari;
2
3
article.putAll({
4
runsOn: LocalDate.of(2026, 8, 14),
5
startsAt: LocalTime.of(9, 30),
6
copyrightYear: Year.of(2026),
7
readingTime: Duration.of({ minutes: 4, seconds: 30 }),
8
retention: Period.of({ years: 1, months: 6 })
9
});

Every date and time class also accepts text, checked against the form the field stores, and from(instant, zone) reads a Date in a zone of your choosing rather than dari.timeZone:

ClassStored asBuilt from parts with
LocalDate2026-08-14LocalDate.of(year, month, day)
LocalTime09:30, with seconds only when they aren't zeroLocalTime.of(hour, minute, second)
LocalDateTime2026-08-14T09:30
OffsetDateTime2026-08-14T09:30-04:00
ZonedDateTime2026-08-14T09:30-04:00[America/New_York]
OffsetTime09:30-04:00
ZoneIdAmerica/New_York
ZoneOffset-04:00, or Z
Year2026, as a numberYear.of(year)
YearMonth2026-08YearMonth.of(year, month)
MonthDay--08-14MonthDay.of(month, day)
DurationPT4M30SDuration.of({ days, hours, minutes, seconds }), ofSeconds, ofMinutes, or Duration.between(start, end)
PeriodP1Y6MPeriod.of({ years, months, days })

Text that isn't in the form is refused:

1
"14/08/2026" is not a valid LocalDate.

A length of time cannot be worked out from a single moment, and the script says so rather than guessing:

1
Field "readingTime" is a duration, which is a span of time rather than a point in one,
2
so a Date cannot say what it should be. Use Duration.of({ ... }).

Was this page helpful?

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.