-
-
Notifications
You must be signed in to change notification settings - Fork 1
String
Alan Berdinelli edited this page Sep 8, 2020
·
3 revisions
String type validates that the value is a string native type. And then checks for the other rules you might have.
const Schemy = require('schemy');
const Example = new Schemy({
data: {
type: String
}
});You can use a custom regex to validate with a custom rule.
const Schemy = require('schemy');
const Example = new Schemy({
data: {
type: String,
// In this example, we validate the value starts with an A followed by 15 characters.
regex: /^a(.{15})$/
}
});Enums allow you to validate the value using a list of valid options.
const Schemy = require('schemy');
const Example = new Schemy({
data: {
type: String,
// In this case. "data" will fail unless is value1 or value2
enum: ['value1','value2']
}
});Developed with ♥ by Alan Berdinelli.