String validations
const User = attributes({
id: {
type: String,
guid: true,
},
token: {
type: String,
guid: {
version: ['uuidv4'],
},
},
initials: {
type: String,
upperCase: true,
maxLength: 4,
},
gender: {
type: String,
nullable: true,
},
password: String,
passwordConfirmation: {
type: String,
equal: { attr: 'password' },
},
greet: {
type: String,
required: true,
equal: ['Mr', 'Ms', 'Mrs', 'Miss', { attr: 'greetDesc' }],
},
greetDesc: String,
})(
class User {
getFullGreet() {
return `${this.greet} ${this.initials}`;
}
}
);Last updated