Created
August 23, 2020 17:37
-
-
Save deebloo/87425c634bf508bb50bf70291fa771a7 to your computer and use it in GitHub Desktop.
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
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