Skip to content
Sergej edited this page Apr 30, 2019 · 1 revision

Specific value

const schema = new Schema<Model>()
    .with(m => m.StringProp, "specificValue")
    .build();

Length

const schema = new Schema<Model>()
    .with(m => m.StringProp, x => x.length >= 10)
    .build();

Supported operators: ==, ===, >=, <=, >, <

Regular Expressions

const schema = new Schema<Model>()
    .with(m => m.StringProp, /^[A-z]+\.[A-z]+$/)
    .build();

Format

const schema = new Schema<Model>()
    .with(m => m.StringProp, new StringSchema({
        format: "date-time"
    }))
    // or
    .with(m => m.StringProp, new StringSchema({
        format: "ipv4"
    }))
    .build();
Clone this wiki locally