Skip to content

Instantly share code, notes, and snippets.

@diegohaz
Created March 11, 2018 23:16
Show Gist options
  • Save diegohaz/6d7e2d4ef4d5dd450b5f1b361cacc597 to your computer and use it in GitHub Desktop.
Save diegohaz/6d7e2d4ef4d5dd450b5f1b361cacc597 to your computer and use it in GitHub Desktop.
const schema = require("schm");
const exclaim = prevSchema => prevSchema.merge({
parsers: {
exclaim: v => `${v}!!!`,
},
});
const userSchema = schema(
{
name: { type: String, exclaim: true },
age: Number,
},
exclaim
);
userSchema.parse({
name: "Haz",
age: 27,
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment