2016-06-23 16:47:54 +00:00
|
|
|
/**
|
|
|
|
|
* @license
|
|
|
|
|
* Copyright Google Inc. All Rights Reserved.
|
|
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
|
|
|
* found in the LICENSE file at https://angular.io/license
|
|
|
|
|
*/
|
|
|
|
|
|
2016-06-08 23:38:52 +00:00
|
|
|
import {Pipe, PipeTransform} from '@angular/core';
|
|
|
|
|
import {isBlank, isString} from '../facade/lang';
|
2016-08-25 07:50:16 +00:00
|
|
|
import {InvalidPipeArgumentError} from './invalid_pipe_argument_error';
|
2015-08-07 18:41:38 +00:00
|
|
|
|
2015-05-14 17:14:26 +00:00
|
|
|
/**
|
|
|
|
|
* Implements uppercase transforms to text.
|
|
|
|
|
*
|
2015-10-19 14:37:32 +00:00
|
|
|
* ### Example
|
2015-05-14 17:14:26 +00:00
|
|
|
*
|
2015-11-02 23:46:59 +00:00
|
|
|
* {@example core/pipes/ts/lowerupper_pipe/lowerupper_pipe_example.ts region='LowerUpperPipe'}
|
2016-05-27 18:24:05 +00:00
|
|
|
*
|
2016-08-23 20:58:41 +00:00
|
|
|
* @stable
|
2015-05-14 17:14:26 +00:00
|
|
|
*/
|
2015-08-07 18:41:38 +00:00
|
|
|
@Pipe({name: 'uppercase'})
|
2015-08-12 19:04:54 +00:00
|
|
|
export class UpperCasePipe implements PipeTransform {
|
2016-04-22 22:33:32 +00:00
|
|
|
transform(value: string): string {
|
2015-08-06 17:39:02 +00:00
|
|
|
if (isBlank(value)) return value;
|
|
|
|
|
if (!isString(value)) {
|
2016-08-25 07:50:16 +00:00
|
|
|
throw new InvalidPipeArgumentError(UpperCasePipe, value);
|
2015-08-06 17:39:02 +00:00
|
|
|
}
|
2015-10-31 20:04:26 +00:00
|
|
|
return value.toUpperCase();
|
2015-05-14 17:14:26 +00:00
|
|
|
}
|
|
|
|
|
}
|