1 | import { buildMessage, ValidateBy } from '../common/ValidateBy';
|
2 | export const IS_FIREBASE_PUSH_ID = 'IsFirebasePushId';
|
3 |
|
4 |
|
5 |
|
6 |
|
7 | export function isFirebasePushId(value) {
|
8 | const webSafeRegex = /^[a-zA-Z0-9_-]*$/;
|
9 | return typeof value === 'string' && value.length === 20 && webSafeRegex.test(value);
|
10 | }
|
11 |
|
12 |
|
13 |
|
14 |
|
15 | export function IsFirebasePushId(validationOptions) {
|
16 | return ValidateBy({
|
17 | name: IS_FIREBASE_PUSH_ID,
|
18 | validator: {
|
19 | validate: (value, args) => isFirebasePushId(value),
|
20 | defaultMessage: buildMessage(eachPrefix => eachPrefix + '$property must be a Firebase Push Id', validationOptions),
|
21 | },
|
22 | }, validationOptions);
|
23 | }
|
24 |
|
\ | No newline at end of file |