Skip to content

Synchronous validation

Alan Berdinelli edited this page Sep 8, 2020 · 1 revision

Every schema created with schemy comes with it's .validate() method, which is synchronous:

const schema = new Schemy({
    title: {
        type: String
    }
});

const data = {title: 'Schemy'};

// Validate first
schema.validate(data);

// Do something else with the data
console.log(data.title);