CodeTanzania / emis-alert

A representation of an entity which provides(or receives) disaster notifications to(or from) source(s)
https://codetanzania.github.io/emis-alert/
MIT License
2 stars 1 forks source link

reduce number of required fields to enable creating Alert with few fields from the map UI #7

Closed Mloweedgar closed 5 years ago

Mloweedgar commented 5 years ago

We agreed required fields should only be event, urgency, certainty, severity, instructions and area

this is the error object I get. may be you could reduce some required fields


{
  status: 400,
  code: 400,
  name: 'ValidationError',
  message: 'Alert validation failed: direction: Path `direction` is required., expiredAt: Path `expiredAt` is required., expectedAt: Path `expectedAt` is required., reportedAt: Path `reportedAt` is required., event.response: Path `response` is required., event.category: Path `category` is required., event.code: Path `code` is required., event.urgency: `expected` is not a valid enum value for path `urgency`., event.severity: `minor` is not a valid enum value for path `severity`., event.certainty: `likely` is not a valid enum value for path `certainty`., message.headline: Path `headline` is required., message.note: Path `note` is required., message.code: Path `code` is required., message.scope: Path `scope` is required., message.type: Path `type` is required., message.status: Path `status` is required., event: Validation failed: response: Path `response` is required., category: Path `category` is required., code: Path `code` is required., urgency: `expected` is not a valid enum value for path `urgency`., severity: `minor` is not a valid enum value for path `severity`., certainty: `likely` is not a valid enum value for path `certainty`., message: Validation failed: headline: Path `headline` is required., note: Path `note` is required., code: Path `code` is required., scope: Path `scope` is required., type: Path `type` is required., status: Path `status` is required.',
  errors: {
    direction: {
      message: 'Path `direction` is required.',
      name: 'ValidatorError',
      properties: {
        message: 'Path `direction` is required.',
        type: 'required',
        path: 'direction'
      },
      kind: 'required',
      path: 'direction',
      $isValidatorError: true
    },
    expiredAt: {
      message: 'Path `expiredAt` is required.',
      name: 'ValidatorError',
      properties: {
        message: 'Path `expiredAt` is required.',
        type: 'required',
        path: 'expiredAt'
      },
      kind: 'required',
      path: 'expiredAt',
      $isValidatorError: true
    },
    expectedAt: {
      message: 'Path `expectedAt` is required.',
      name: 'ValidatorError',
      properties: {
        message: 'Path `expectedAt` is required.',
        type: 'required',
        path: 'expectedAt'
      },
      kind: 'required',
      path: 'expectedAt',
      $isValidatorError: true
    },
    reportedAt: {
      message: 'Path `reportedAt` is required.',
      name: 'ValidatorError',
      properties: {
        message: 'Path `reportedAt` is required.',
        type: 'required',
        path: 'reportedAt'
      },
      kind: 'required',
      path: 'reportedAt',
      $isValidatorError: true
    },
    'event.response': {
      message: 'Path `response` is required.',
      name: 'ValidatorError',
      properties: {
        message: 'Path `response` is required.',
        type: 'required',
        path: 'response'
      },
      kind: 'required',
      path: 'response',
      $isValidatorError: true
    },
    'event.category': {
      message: 'Path `category` is required.',
      name: 'ValidatorError',
      properties: {
        message: 'Path `category` is required.',
        type: 'required',
        path: 'category'
      },
      kind: 'required',
      path: 'category',
      $isValidatorError: true
    },
    'event.code': {
      message: 'Path `code` is required.',
      name: 'ValidatorError',
      properties: {
        message: 'Path `code` is required.',
        type: 'required',
        path: 'code'
      },
      kind: 'required',
      path: 'code',
      $isValidatorError: true
    },
    'event.urgency': {
      message: '`expected` is not a valid enum value for path `urgency`.',
      name: 'ValidatorError',
      properties: {
        message: '`expected` is not a valid enum value for path `urgency`.',
        type: 'enum',
        enumValues: [
          'Immediate',
          'Expected',
          'Future',
          'Past',
          'Unknown'
        ],
        path: 'urgency',
        value: 'expected'
      },
      kind: 'enum',
      path: 'urgency',
      value: 'expected',
      $isValidatorError: true
    },
    'event.severity': {
      message: '`minor` is not a valid enum value for path `severity`.',
      name: 'ValidatorError',
      properties: {
        message: '`minor` is not a valid enum value for path `severity`.',
        type: 'enum',
        enumValues: [
          'Extreme',
          'Severe',
          'Moderate',
          'Minor',
          'Unknown'
        ],
        path: 'severity',
        value: 'minor'
      },
      kind: 'enum',
      path: 'severity',
      value: 'minor',
      $isValidatorError: true
    },
    'event.certainty': {
      message: '`likely` is not a valid enum value for path `certainty`.',
      name: 'ValidatorError',
      properties: {
        message: '`likely` is not a valid enum value for path `certainty`.',
        type: 'enum',
        enumValues: [
          'Observed',
          'Likely',
          'Possible',
          'Unlikely',
          'Unknown'
        ],
        path: 'certainty',
        value: 'likely'
      },
      kind: 'enum',
      path: 'certainty',
      value: 'likely',
      $isValidatorError: true
    },
    'message.headline': {
      message: 'Path `headline` is required.',
      name: 'ValidatorError',
      properties: {
        message: 'Path `headline` is required.',
        type: 'required',
        path: 'headline'
      },
      kind: 'required',
      path: 'headline',
      $isValidatorError: true
    },
    'message.note': {
      message: 'Path `note` is required.',
      name: 'ValidatorError',
      properties: {
        message: 'Path `note` is required.',
        type: 'required',
        path: 'note'
      },
      kind: 'required',
      path: 'note',
      $isValidatorError: true
    },
    'message.code': {
      message: 'Path `code` is required.',
      name: 'ValidatorError',
      properties: {
        message: 'Path `code` is required.',
        type: 'required',
        path: 'code'
      },
      kind: 'required',
      path: 'code',
      $isValidatorError: true
    },
    'message.scope': {
      message: 'Path `scope` is required.',
      name: 'ValidatorError',
      properties: {
        message: 'Path `scope` is required.',
        type: 'required',
        path: 'scope'
      },
      kind: 'required',
      path: 'scope',
      $isValidatorError: true
    },
    'message.type': {
      message: 'Path `type` is required.',
      name: 'ValidatorError',
      properties: {
        message: 'Path `type` is required.',
        type: 'required',
        path: 'type'
      },
      kind: 'required',
      path: 'type',
      $isValidatorError: true
    },
    'message.status': {
      message: 'Path `status` is required.',
      name: 'ValidatorError',
      properties: {
        message: 'Path `status` is required.',
        type: 'required',
        path: 'status'
      },
      kind: 'required',
      path: 'status',
      $isValidatorError: true
    },
    event: {
      errors: {
        response: {
          message: 'Path `response` is required.',
          name: 'ValidatorError',
          properties: {
            message: 'Path `response` is required.',
            type: 'required',
            path: 'response'
          },
          kind: 'required',
          path: 'response',
          $isValidatorError: true
        },
        category: {
          message: 'Path `category` is required.',
          name: 'ValidatorError',
          properties: {
            message: 'Path `category` is required.',
            type: 'required',
            path: 'category'
          },
          kind: 'required',
          path: 'category',
          $isValidatorError: true
        },
        code: {
          message: 'Path `code` is required.',
          name: 'ValidatorError',
          properties: {
            message: 'Path `code` is required.',
            type: 'required',
            path: 'code'
          },
          kind: 'required',
          path: 'code',
          $isValidatorError: true
        },
        urgency: {
          message: '`expected` is not a valid enum value for path `urgency`.',
          name: 'ValidatorError',
          properties: {
            message: '`expected` is not a valid enum value for path `urgency`.',
            type: 'enum',
            enumValues: [
              'Immediate',
              'Expected',
              'Future',
              'Past',
              'Unknown'
            ],
            path: 'urgency',
            value: 'expected'
          },
          kind: 'enum',
          path: 'urgency',
          value: 'expected',
          $isValidatorError: true
        },
        severity: {
          message: '`minor` is not a valid enum value for path `severity`.',
          name: 'ValidatorError',
          properties: {
            message: '`minor` is not a valid enum value for path `severity`.',
            type: 'enum',
            enumValues: [
              'Extreme',
              'Severe',
              'Moderate',
              'Minor',
              'Unknown'
            ],
            path: 'severity',
            value: 'minor'
          },
          kind: 'enum',
          path: 'severity',
          value: 'minor',
          $isValidatorError: true
        },
        certainty: {
          message: '`likely` is not a valid enum value for path `certainty`.',
          name: 'ValidatorError',
          properties: {
            message: '`likely` is not a valid enum value for path `certainty`.',
            type: 'enum',
            enumValues: [
              'Observed',
              'Likely',
              'Possible',
              'Unlikely',
              'Unknown'
            ],
            path: 'certainty',
            value: 'likely'
          },
          kind: 'enum',
          path: 'certainty',
          value: 'likely',
          $isValidatorError: true
        }
      },
      _message: 'Validation failed',
      message: 'Validation failed: response: Path `response` is required., category: Path `category` is required., code: Path `code` is required., urgency: `expected` is not a valid enum value for path `urgency`., severity: `minor` is not a valid enum value for path `severity`., certainty: `likely` is not a valid enum value for path `certainty`.',
      name: 'ValidationError'
    },
    message: {
      errors: {
        headline: {
          message: 'Path `headline` is required.',
          name: 'ValidatorError',
          properties: {
            message: 'Path `headline` is required.',
            type: 'required',
            path: 'headline'
          },
          kind: 'required',
          path: 'headline',
          $isValidatorError: true
        },
        note: {
          message: 'Path `note` is required.',
          name: 'ValidatorError',
          properties: {
            message: 'Path `note` is required.',
            type: 'required',
            path: 'note'
          },
          kind: 'required',
          path: 'note',
          $isValidatorError: true
        },
        code: {
          message: 'Path `code` is required.',
          name: 'ValidatorError',
          properties: {
            message: 'Path `code` is required.',
            type: 'required',
            path: 'code'
          },
          kind: 'required',
          path: 'code',
          $isValidatorError: true
        },
        scope: {
          message: 'Path `scope` is required.',
          name: 'ValidatorError',
          properties: {
            message: 'Path `scope` is required.',
            type: 'required',
            path: 'scope'
          },
          kind: 'required',
          path: 'scope',
          $isValidatorError: true
        },
        type: {
          message: 'Path `type` is required.',
          name: 'ValidatorError',
          properties: {
            message: 'Path `type` is required.',
            type: 'required',
            path: 'type'
          },
          kind: 'required',
          path: 'type',
          $isValidatorError: true
        },
        status: {
          message: 'Path `status` is required.',
          name: 'ValidatorError',
          properties: {
            message: 'Path `status` is required.',
            type: 'required',
            path: 'status'
          },
          kind: 'required',
          path: 'status',
          $isValidatorError: true
        }
      },
      _message: 'Validation failed',
      message: 'Validation failed: headline: Path `headline` is required., note: Path `note` is required., code: Path `code` is required., scope: Path `scope` is required., type: Path `type` is required., status: Path `status` is required.',
      name: 'ValidationError'
    }
  },
  developerMessage: 'Alert validation failed: direction: Path `direction` is required., expiredAt: Path `expiredAt` is required., expectedAt: Path `expectedAt` is required., reportedAt: Path `reportedAt` is required., event.response: Path `response` is required., event.category: Path `category` is required., event.code: Path `code` is required., event.urgency: `expected` is not a valid enum value for path `urgency`., event.severity: `minor` is not a valid enum value for path `severity`., event.certainty: `likely` is not a valid enum value for path `certainty`., message.headline: Path `headline` is required., message.note: Path `note` is required., message.code: Path `code` is required., message.scope: Path `scope` is required., message.type: Path `type` is required., message.status: Path `status` is required., event: Validation failed: response: Path `response` is required., category: Path `category` is required., code: Path `code` is required., urgency: `expected` is not a valid enum value for path `urgency`., severity: `minor` is not a valid enum value for path `severity`., certainty: `likely` is not a valid enum value for path `certainty`., message: Validation failed: headline: Path `headline` is required., note: Path `note` is required., code: Path `code` is required., scope: Path `scope` is required., type: Path `type` is required., status: Path `status` is required.',
  userMessage: 'Alert validation failed: direction: Path `direction` is required., expiredAt: Path `expiredAt` is required., expectedAt: Path `expectedAt` is required., reportedAt: Path `reportedAt` is required., event.response: Path `response` is required., event.category: Path `category` is required., event.code: Path `code` is required., event.urgency: `expected` is not a valid enum value for path `urgency`., event.severity: `minor` is not a valid enum value for path `severity`., event.certainty: `likely` is not a valid enum value for path `certainty`., message.headline: Path `headline` is required., message.note: Path `note` is required., message.code: Path `code` is required., message.scope: Path `scope` is required., message.type: Path `type` is required., message.status: Path `status` is required., event: Validation failed: response: Path `response` is required., category: Path `category` is required., code: Path `code` is required., urgency: `expected` is not a valid enum value for path `urgency`., severity: `minor` is not a valid enum value for path `severity`., certainty: `likely` is not a valid enum value for path `certainty`., message: Validation failed: headline: Path `headline` is required., note: Path `note` is required., code: Path `code` is required., scope: Path `scope` is required., type: Path `type` is required., status: Path `status` is required.',
  error: 'ValidationError',
  error_description: 'Alert validation failed: direction: Path `direction` is required., expiredAt: Path `expiredAt` is required., expectedAt: Path `expectedAt` is required., reportedAt: Path `reportedAt` is required., event.response: Path `response` is required., event.category: Path `category` is required., event.code: Path `code` is required., event.urgency: `expected` is not a valid enum value for path `urgency`., event.severity: `minor` is not a valid enum value for path `severity`., event.certainty: `likely` is not a valid enum value for path `certainty`., message.headline: Path `headline` is required., message.note: Path `note` is required., message.code: Path `code` is required., message.scope: Path `scope` is required., message.type: Path `type` is required., message.status: Path `status` is required., event: Validation failed: response: Path `response` is required., category: Path `category` is required., code: Path `code` is required., urgency: `expected` is not a valid enum value for path `urgency`., severity: `minor` is not a valid enum value for path `severity`., certainty: `likely` is not a valid enum value for path `certainty`., message: Validation failed: headline: Path `headline` is required., note: Path `note` is required., code: Path `code` is required., scope: Path `scope` is required., type: Path `type` is required., status: Path `status` is required.'
}
Mloweedgar commented 5 years ago

@lykmapipo Here is the payload I sent:


{
  event: {
    name: 'Flood and Landslide',
    urgency: 'Expected',
    severity: 'Minor',
    certainty: 'Likely'
  },
  message: {
    instruction: 'this is for testing purpose only'
  },
  area: {
    geometry: {
      type: 'Feature',
      properties: {},
      geometry: {
        type: 'Polygon',
        coordinates: [
          [
            [
              38.17749,
              -9.373193
            ],
            [
              38.188477,
              -9.698228
            ],
            [
              38.583984,
              -9.665738
            ],
            [
              38.62793,
              -9.308149
            ],
            [
              38.17749,
              -9.373193
            ]
          ]
        ]
      }
    }
  }
}
lykmapipo commented 5 years ago

@Mloweedgar Please see the structure of payload below for reference

{
    "source":
    {
        "name": "Tanzania Meteorological Agency",
        "phone": "255 22 2460706-8",
        "email": "severe@meteo.go.tz",
        "website": "met@meteo.go.tz"
    },
    "event":
    {
        "name": "Iusto dolores blanditiis vero.",
        "category": "Geo",
        "urgency": "Past",
        "severity": "Unknown",
        "certainty": "Likely",
        "response": "Monitor"
    },
    "message":
    {
        "instruction": "Assumenda animi fuga placeat excepturi."
    },
    "area":
    {
        "description": "Bedfordshire",
        "geometry":
        {
            "type": "Polygon",
            "coordinates": [
                [
                    [38.17749, -9.373193],
                    [38.188477, -9.698228],
                    [38.583984, -9.665738],
                    [38.62793, -9.308149],
                    [38.17749, -9.373193]
                ]
            ]
        }
    }
}