Module: CommandTower::Messaging::Endpoints::Validators::Push
- Defined in:
- app/services/command_tower/messaging/endpoints/validators/push.rb
Constant Summary collapse
- EXPO_TOKEN =
Expo push token forms used by expo-notifications / Expo Push API.
/\A(ExponentPushToken|ExpoPushToken)\[[^\]]+\]\z/
Class Method Summary collapse
Class Method Details
.validate!(address) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'app/services/command_tower/messaging/endpoints/validators/push.rb', line 13 def validate!(address) token = address.to_s.strip raise ValidationError, "push token must be present" if token.empty? raise ValidationError, "push token is too short" if token.length < 8 unless token.match?(EXPO_TOKEN) raise ValidationError, "push token must be an Expo push token (ExponentPushToken[...] or ExpoPushToken[...])" end Result.new( normalized_address: token, masked_display_value: "Device registered", ) end |