#! writes: 3
#! expect: [false, true, true]
# `key: value if cond` omits the key when the condition fails; the write
# schema's optional properties accept the omission.
contacts = data.contacts()
flags = for c in contacts limit 4 {
needs_fix = not regex.test(c.phone, "^\\+1[0-9]{10}$")
r = write.update({
id: c.id,
phone: ("+" + regex.replace(c.phone, "[^0-9]", "")) if needs_fix,
company: c.company if c.company != ""
})
return needs_fix
}
return flags