Skip to content

Instantly share code, notes, and snippets.

View diegohaz's full-sized avatar

Haz diegohaz

View GitHub Profile
const Avatar = ({ profile, ...props }) => (
<img
className="avatar"
src={profile && profile.photoUrl}
alt={profile && profile.photoAlt}
{...props}
/>
);
Avatar.propTypes = {
const Avatar = ({ profile, ...props }) => (
<img
className="avatar"
src={profile.photoSrc}
alt={profile.photoAlt}
{...props}
/>
);
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);
}
});
const schema = require("schm");
const translate = require("schm-translate");
const userSchema = schema({
name: String,
email: String,
}, translate({
email: "emails.0",
}));
const schema = require("schm");
const exclaim = prevSchema => prevSchema.merge({
parsers: {
exclaim: v => `${v}!!!`,
},
});
const userSchema = schema(
{
const schema = require("schm");
const roleSchema = schema({
title: String,
permissions: [String],
});
const userSchema = schema({
name: String,
age: Number,
const schema = require("schm");
const identitySchema = schema({
name: String,
birthdate: Date,
});
const bodySchema = schema({
height: Number,
weight: Number,
const schema = require("schm");
const userSchema = schema({
name: String,
age: { type: Number, min: 18 },
});
await userSchema.validate({
name: "John",
age: 17,
const schema = require("schm");
const userSchema = schema({
name: { type: String, uppercase: true },
birthdate: Date,
});
userSchema.parse({
name: "Haz",
birthdate: "1990-04-10",
const schema = require("schm");
const userSchema = schema({
name: { type: String, default: "Haz" },
age: { type: Number, default: 27 },
});