Heap.RegEx
Declares a string field validated using a specified regular expression.
Usage / Signature
import { Heap } from '@app/heap'
Heap.RegEx(regex, options)
Arguments
-
<b id="regex">regex</b>:
{RegExp}<b style="color:red">*</b>
A regular expression, an instance of RegExp, which will be assigned to the pattern property. The flags of the regular expression will be ignored (see the description of thepatternproperty in Heap.String). -
<b id="options">options</b>:
{default}
An object with additional optional parameters for the field.- <b id="default">default</b>:
string
The default value for this field. For more information on how default values work, see Guide / Heap / Default Values.
- <b id="default">default</b>:
Return Value
A JSON schema for a string field.
Examples
Only lowercase Latin letters
const products = Heap.Table('products', {
partno: Heap.RegEx(/^[a-z]+$/),
})
Must start with an uppercase Latin letter, plus a default value
const customers = Heap.Table('customers', {
latinName: Heap.RegEx(new RegExp("^[A-Z]"), { default: "Test" }),
})