Skip to content
This repository has been archived by the owner on May 7, 2021. It is now read-only.

Commit

Permalink
fix(spaces): provide more validation error info
Browse files Browse the repository at this point in the history
Encapsulation FTW!
  • Loading branch information
pmuir authored and joshuawilson committed Mar 16, 2017
1 parent da64797 commit f8a2bce
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions src/app/spaces/valid-space-name.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,31 @@ export function validSpaceNameValidator(): AsyncValidatorFn {
.takeUntil(changed$)
.map(value => {
if (!control.value || control.value.toString().length > ValidSpaceNameValidatorDirective.MAX_SPACE_NAME_LENGTH) {
return { maxLength: { valid: false, requestedName: control.value } };
return {
maxLength: {
valid: false,
requestedName: control.value,
max: ValidSpaceNameValidatorDirective.MAX_SPACE_NAME_LENGTH,
}
};
}
let strVal: string = control.value.toString();
if (strVal.length < ValidSpaceNameValidatorDirective.MIN_SPACE_NAME_LENGTH) {
return { minLength: { valid: false, requestedName: control.value } };
return {
minLength: {
valid: false,
requestedName: control.value,
min: ValidSpaceNameValidatorDirective.MIN_SPACE_NAME_LENGTH
}
};
} else if (!strVal.match(ValidSpaceNameValidatorDirective.ALLOWED_SPACE_NAMES)) {
return { invalid: { valid: false, requestedName: control.value } };
return {
invalid: {
valid: false,
requestedName: control.value,
allowedChars: ValidSpaceNameValidatorDirective.ALLOWED_SPACE_NAMES
}
};
}
return null;
})
Expand Down

0 comments on commit f8a2bce

Please sign in to comment.