Skip to content
This repository was archived by the owner on Feb 9, 2023. It is now read-only.

Ensure that author preamble has handle or email #44

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/error.rs
Original file line number Diff line number Diff line change
@@ -40,6 +40,7 @@ pub enum Error {
UnmatchedEmailDelimiter,
UnmatchedHandleDelimiter,
AuthorHasEmailAndHandle,
AuthorHasNoContactDetails,
TrailingInfoAfterEmail,
TrailingInfoAfterHandle,
MalformedEmail,
@@ -98,6 +99,7 @@ impl Error {
Self::UnmatchedEmailDelimiter => "unmatched email delimiter",
Self::UnmatchedHandleDelimiter => "unmatched handle delimiter",
Self::AuthorHasEmailAndHandle => "author can't include both an email and handle",
Self::AuthorHasNoContactDetails => "author has no contact details",
Self::TrailingInfoAfterEmail => "trailing information after email",
Self::TrailingInfoAfterHandle => "trailing information after handle",
Self::MalformedEmail => "malformed email",
4 changes: 4 additions & 0 deletions src/validators.rs
Original file line number Diff line number Diff line change
@@ -141,6 +141,10 @@ fn validate_author<'a>(acc: &mut Vec<String>, s: &str) -> Result<()> {
return Err(Error::AuthorHasEmailAndHandle);
}

if email_start.is_some() == false && handle_start.is_some() == false {
return Err(Error::AuthorHasNoContactDetails);
}

if email_start.is_some() {
let start = email_start.unwrap();
let end = email_end.unwrap();
39 changes: 39 additions & 0 deletions tests/fixtures/preamble-author-no-contact.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
eip: 1
title: A sample proposal
author: John Doe
discussions-to: https://example.com
status: Draft
type: Standards Track
category: Core
created: 2020-01-01
updated: 2020-01-01
requires: 20, 1337, 2048
---

## Abstract
This is the abstract for the EIP.

## Motivation
This is the motivation for the EIP.

## Specification
This is the specification for the EIP.

## Rationale
This is the rationale for the EIP.

## Backwards Compatibility
These are the backwards compatibility concerns for the EIP.

## Test Cases
These are the test cases for the EIP.

## Implementation
This is the implementation for the EIP.

## Security Considerations
These are the security considerations for the EIP.

## Copyright
Copyright and related rights waived via [CC0](https://creativecommons.org/publicdomain/zero/1.0/).
4 changes: 4 additions & 0 deletions tests/tests.rs
Original file line number Diff line number Diff line change
@@ -158,6 +158,10 @@ fn preamble_author() {
);
test_fixture("preamble-author-email-invalid.md", "malformed email");
test_fixture("preamble-author-handle-invalid.md", "malformed handle");
test_fixture(
"preamble-author-no-contact.md",
"author has no contact details",
);
}

#[test]