Skip to content

Instantly share code, notes, and snippets.

@deebloo
Created August 23, 2020 17:37
Show Gist options
  • Save deebloo/87425c634bf508bb50bf70291fa771a7 to your computer and use it in GitHub Desktop.
Save deebloo/87425c634bf508bb50bf70291fa771a7 to your computer and use it in GitHub Desktop.
import { component, property, JoistElement } from '@joist/component';
function isString(val: unknown) {
if (typeof val === 'string') {
return null;
}
return { message: 'error' };
}
function isLongerThan(length: number) {
return function (val: string) {
if (val.length > length) {
return null;
}
return { message: 'Incorrect length' };
}
@component()
class MyElement extends JoistElement {
@property(isString, isLongerThan(2))
public hello = 'Hello World';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment