This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Avatar = ({ profile, ...props }) => ( | |
<img | |
className="avatar" | |
src={profile && profile.photoUrl} | |
alt={profile && profile.photoAlt} | |
{...props} | |
/> | |
); | |
Avatar.propTypes = { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Avatar = ({ profile, ...props }) => ( | |
<img | |
className="avatar" | |
src={profile.photoSrc} | |
alt={profile.photoAlt} | |
{...props} | |
/> | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const schema = require("schm"); | |
const Joi = require("joi"); | |
const joiValidate = constraints => prevSchema => prevSchema.merge({ | |
validate(values) { | |
const parsed = prevSchema.parse(values); | |
return Joi.validate(parsed, constraints); | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const schema = require("schm"); | |
const translate = require("schm-translate"); | |
const userSchema = schema({ | |
name: String, | |
email: String, | |
}, translate({ | |
email: "emails.0", | |
})); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const schema = require("schm"); | |
const exclaim = prevSchema => prevSchema.merge({ | |
parsers: { | |
exclaim: v => `${v}!!!`, | |
}, | |
}); | |
const userSchema = schema( | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const schema = require("schm"); | |
const roleSchema = schema({ | |
title: String, | |
permissions: [String], | |
}); | |
const userSchema = schema({ | |
name: String, | |
age: Number, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const schema = require("schm"); | |
const identitySchema = schema({ | |
name: String, | |
birthdate: Date, | |
}); | |
const bodySchema = schema({ | |
height: Number, | |
weight: Number, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const schema = require("schm"); | |
const userSchema = schema({ | |
name: String, | |
age: { type: Number, min: 18 }, | |
}); | |
await userSchema.validate({ | |
name: "John", | |
age: 17, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const schema = require("schm"); | |
const userSchema = schema({ | |
name: { type: String, uppercase: true }, | |
birthdate: Date, | |
}); | |
userSchema.parse({ | |
name: "Haz", | |
birthdate: "1990-04-10", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const schema = require("schm"); | |
const userSchema = schema({ | |
name: { type: String, default: "Haz" }, | |
age: { type: Number, default: 27 }, | |
}); |