Skip to content

Commit

Permalink
fix(validation): change header max length to 72
Browse files Browse the repository at this point in the history
the previous spec was wrong the expectation was the maximum length was of 100
but its actually 72 which has now been updated and put on a variable for easier
access case it changes in the future
  • Loading branch information
cainakleao authored and hassankhan committed Nov 15, 2018
1 parent 459cbe4 commit c98d52d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/lib/validation/validateSubject.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import validateSubject from './validateSubject';
import validateSubject, { MAXIMUM_LENGTH } from './validateSubject';

describe('#validateSubject', () => {
it('prevents commits if no subject specified', () => {
Expand All @@ -16,7 +16,7 @@ describe('#validateSubject', () => {
).toContain('first word must be lowercase');
});

it('prevents commits if header is greater than 100 characters', () => {
it(`prevents commits if header is greater than ${MAXIMUM_LENGTH} characters`, () => {
expect(
validateSubject(
'lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut',
Expand Down
7 changes: 5 additions & 2 deletions src/lib/validation/validateSubject.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import validateLowercase from './validateLowercase';

export const MAXIMUM_LENGTH = 72;

export default (input: string, answers: any) => {
if (!input || input === '') {
return 'Must specify subject';
Expand All @@ -15,9 +17,10 @@ export default (input: string, answers: any) => {

const inputSize = input.length;

if (typeSize + scopeSize + inputSize <= 100) {
if (typeSize + scopeSize + inputSize <= MAXIMUM_LENGTH) {
return true;
}

return `Subject should be ${100 - (typeSize + scopeSize)} characters or less`;
return `Subject should be ${MAXIMUM_LENGTH -
(typeSize + scopeSize)} characters or less`;
};

0 comments on commit c98d52d

Please sign in to comment.